Java Doc for DatabaseStorageManager.java in  » Database-ORM » MMBase » org » mmbase » storage » implementation » database » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » MMBase » org.mmbase.storage.implementation.database 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.mmbase.storage.implementation.database.DatabaseStorageManager

All known Subclasses:   org.mmbase.storage.implementation.database.InformixStorageManager,  org.mmbase.storage.implementation.database.RelationalDatabaseStorageManager,  org.mmbase.storage.implementation.database.ViewDatabaseStorageManager,
DatabaseStorageManager
public class DatabaseStorageManager implements StorageManager(Code)
A JDBC implementation of an object related storage manager.
author:
   Pierre van Rooden
since:
   MMBase-1.7
version:
   $Id: DatabaseStorageManager.java,v 1.189 2008/02/18 12:43:17 michiel Exp $

Inner Class :protected static class InputStreamBlob implements Blob

Field Summary
final public static  intOBJ2TYPE_MAX_SIZE
    
protected  ConnectionactiveConnection
     The currently active Connection.
final protected  Map<MMObjectNode, String>changes
    
protected  DatabaseStorageManagerFactoryfactory
    
protected  booleaninTransaction
     true if a transaction has been started.
final protected static  List<Integer>sequenceKeys
    
protected  inttransactionIsolation
     The transaction issolation level to use when starting a transaction.
protected static  Cache<Integer, Integer>typeCache
    

Constructor Summary
public  DatabaseStorageManager()
    

Method Summary
protected  voidaddToTableNameCache(String name)
    
public  voidbeginTransaction()
    
public  voidchange(MMObjectNode node)
    
protected  voidchange(MMObjectNode node, MMObjectBuilder builder)
     Change this node in the specified builder.
protected  voidchange(MMObjectNode node, MMObjectBuilder builder, String tableName, Collection<CoreField> changeFields)
    
public  voidchange(MMObjectBuilder builder)
    
public  voidchange(CoreField field)
    
protected  FilecheckFile(File binaryFile, MMObjectNode node, CoreField field)
     Checks whether file is readable and existing.
public  voidcommit()
    
protected  voidcommitChange(MMObjectNode node, String change)
     Commits the change to a node.
public  intconvertLegacyBinaryFiles()
     Convert legacy file Number of converted fields.
public  intcreate(MMObjectNode node)
    
protected  voidcreate(MMObjectNode node, MMObjectBuilder builder)
     This method inserts a new object in a specific builder, and registers the change. This method makes it easier to implement relational databases, where you may need to update the node in more than one builder. Call this method for all involved builders if you use a relational database.
Parameters:
  node - The node to insert.
protected  voidcreate(MMObjectNode node, List<CoreField> createFields, String tablename)
    
public  voidcreate(MMObjectBuilder builder)
    
public  voidcreate()
    
protected  voidcreate(Index index)
     Create an index or a unique constraint.
public  voidcreate(CoreField field)
    
protected  voidcreateIndex(Index index, String tablename)
     Create an index or a unique constraint.
protected  voidcreateIndices(CoreField field)
     (Re)create all constraints and indices that contain a specific field.
public  intcreateKey()
    
protected  voidcreateSequence()
     Creates a means for the database to pre-create keys with increasing numbers.
protected  voidcreateTable(MMObjectBuilder builder, List<CoreField> tableFields, String tableName)
    
public  voiddelete(MMObjectNode node)
    
protected  voiddelete(MMObjectNode node, MMObjectBuilder builder)
     Delete a node from a specific builder This method makes it easier to implement relational databses, where you may need to remove the node in more than one builder.
protected  voiddelete(MMObjectNode node, MMObjectBuilder builder, List<CoreField> blobFileField, String tablename)
    
public synchronized  voiddelete(MMObjectBuilder builder)
    
protected  voiddelete(Index index)
     Drop a constraint or index.
public  voiddelete(CoreField field)
    
protected  voiddeleteIndices(CoreField field)
     Drop all constraints and indices that contain a specific field.
protected  voidexecuteUpdate(String query, MMObjectNode node, List<CoreField> fields)
     Executes an update query for given node and fields.
protected  voidexecuteUpdateCheckConnection(String query, MMObjectNode node, List<CoreField> fields)
     Executes an update query for given node and fields.
public  booleanexists(MMObjectBuilder builder)
    
protected synchronized  booleanexists(String tableName)
     Queries the database metadata to test whether a given table exists.
public  booleanexists()
    
protected  booleanexists(Index index, String tablename)
     Determines if an index exists.
protected  booleanexists(Index index)
     Determines if an index exists.
protected  voidfillNode(MMObjectNode node, ResultSet result, MMObjectBuilder builder)
     Fills a single Node from the resultset of a query.
protected  ConnectiongetActiveConnection()
     Obtains an active connection, opening a new one if needed.
protected  FilegetBinaryFile(MMObjectNode node, String fieldName)
     Defines how binary (blob) data files must look like.
public  byte[]getBinaryValue(MMObjectNode node, CoreField field)
    
protected  BlobgetBlobFromDatabase(MMObjectNode node, CoreField field, boolean mayShorten)
    
protected  BlobgetBlobFromFile(MMObjectNode node, CoreField field, boolean mayShorten)
    
public  BlobgetBlobValue(MMObjectNode node, CoreField field)
    
public  BlobgetBlobValue(MMObjectNode node, CoreField field, boolean mayShorten)
    
protected  BlobgetBlobValue(ResultSet result, int index, CoreField field, boolean mayShorten)
     Retrieve a large binary object (byte array) for a specified object field. The default method uses ResultSet.getBytes(int) to obtain text. Override this method if you want to optimize retrieving large objects, i.e by using clobs or streams.
Parameters:
  result - the resultset to retrieve the text from
Parameters:
  index - the index of the text in the resultset, or -1 to retireiv from file (blobs).
Parameters:
  field - the (MMBase) fieldtype.
protected  BooleangetBooleanValue(ResultSet result, int index, CoreField field)
     Retrieve a boolean value for a specified object field. The default method uses ResultSet.getBoolean(int) to obtain the date.
Parameters:
  result - the resultset to retrieve the value from
Parameters:
  index - the index of the value in the resultset
Parameters:
  field - the (MMBase) fieldtype.
protected  StringgetConstraintDefinition(CoreField field)
     Creates an index definition string for a field to be passed when creating a table.
protected  java.util.DategetDateTimeValue(ResultSet result, int index, CoreField field)
     Retrieve a date for a specified object field. The default method uses ResultSet.getTimestamp(int) to obtain the date.
Parameters:
  result - the resultset to retrieve the value from
Parameters:
  index - the index of the value in the resultset
Parameters:
  field - the (MMBase) fieldtype.
protected  StringgetFieldDefinition(CoreField field)
     Creates a fielddefinition, of the format '[fieldname] [fieldtype] NULL' or '[fieldname] [fieldtype] NOT NULL' (depending on whether the field is nullable).
protected  StringgetFieldList(Index index)
     Returns a comma seperated list of fieldnames for an index.
protected  StringgetFieldTypeDefinition(CoreField field)
     Creates a field type definition, of the format '[fieldtype] NULL' or '[fieldtype] NOT NULL' (depending on whether the field is nullable).
public  InputStreamgetInputStreamValue(MMObjectNode node, CoreField field)
    
protected  intgetJDBCtoField(int jdbcType, int mmbaseType)
     Guess the (mmbase) type in storage using the JDBC type.
protected  longgetLogStartTime()
    
public  MMObjectNodegetNode(MMObjectBuilder builder, int number)
    
public  intgetNodeType(int number)
    
public  StringgetStringValue(MMObjectNode node, CoreField field)
    
protected  ObjectgetStringValue(ResultSet result, int index, CoreField field, boolean mayShorten)
     Retrieve a text for a specified object field. The default method uses ResultSet.getString(int) to obtain text. Override this method if you want to optimize retrieving large texts, i.e by using clobs or streams.
Parameters:
  result - the resultset to retrieve the text from
Parameters:
  index - the index of the text in the resultset
Parameters:
  field - the (MMBase) fieldtype.
public  ObjectgetValue(ResultSet result, int index, CoreField field, boolean mayShorten)
     Attempts to return a single field value from the resultset of a query.
Parameters:
  result - the resultset
Parameters:
  index - the index of the field in the resultset
Parameters:
  field - the expected MMBase field type.
public  doublegetVersion()
    
protected  ObjectgetXMLValue(ResultSet result, int index, CoreField field, boolean mayShorten)
     Retrieve the XML (as a string) for a specified object field. The default method uses ResultSet.getString(int) to obtain text. Unlike Override this method if you want to optimize retrieving large texts, i.e by using clobs or streams.
Parameters:
  result - the resultset to retrieve the xml from
Parameters:
  index - the index of the xml in the resultset
Parameters:
  field - the (MMBase) fieldtype.
public  voidinit(StorageManagerFactory factory)
    
protected  booleanisPartOfBuilderDefinition(CoreField field)
     Determines whether the storage should make a field definition in a builder table for a specified field.
public  booleanisVerified(MMObjectBuilder builder)
     Check if builders are already verified with the database.
final protected  voidlogQuery(String query, long startTime)
    
protected  voidrefresh(MMObjectNode node)
     Reloads the data from a node from the database.
protected  voidreleaseActiveConnection()
     Safely closes the active connection.
public  booleanrollback()
    
protected  voidsetBinaryValue(PreparedStatement statement, int index, Object objectValue, CoreField field, MMObjectNode node)
     Store binary data of a field in a prepared statement. This basic implementation uses a binary stream to set the data. Null values are stored as NULL if possible, otherwise they are stored as an empty byte-array. Override this method if you use another way to store binaries (i.e.
protected  voidsetBooleanValue(PreparedStatement statement, int index, Object value, CoreField field, MMObjectNode node)
     Store a boolean value of a field in a prepared statement. The method uses the Casting class to convert to the appropriate value. Null values are stored as NULL if possible, otherwise they are stored as false Override this method if you use another way to store booleans
Parameters:
  statement - the prepared statement
Parameters:
  index - the index of the field in the prepared statement
Parameters:
  value - the data (boolean) to store
Parameters:
  field - the MMBase field, containing meta-information
Parameters:
  node - the node that contains the data.
protected  voidsetDateTimeValue(PreparedStatement statement, int index, Object value, CoreField field, MMObjectNode node)
     Store a Date value of a field in a prepared statement. The method uses the Casting class to convert to the appropriate value. Null values are stored as NULL if possible, otherwise they are stored as the date 31/12/1969 23:59:59 GMT (-1) TODO: I think that is -1000, not -1. Override this method if you use another way to store dates
Parameters:
  statement - the prepared statement
Parameters:
  index - the index of the field in the prepared statement
Parameters:
  value - the data (date) to store
Parameters:
  field - the MMBase field, containing meta-information
Parameters:
  node - the node that contains the data.
protected  voidsetListValue(PreparedStatement statement, int index, Object value, CoreField field, MMObjectNode node)
     Store a List value of a field in a prepared statement. The method uses the Casting class to convert to the appropriate value. Null values are stored as NULL if possible, otherwise they are stored as an empty list. Override this method if you use another way to store lists
Parameters:
  statement - the prepared statement
Parameters:
  index - the index of the field in the prepared statement
Parameters:
  value - the data (List) to store
Parameters:
  field - the MMBase field, containing meta-information.
protected  voidsetNodeValue(PreparedStatement statement, int index, Object nodeValue, CoreField field, MMObjectNode node)
     Store a node value of a field in a prepared statement Nodes are stored in the database as numeric values. Since a node value can be a (referential) key (depending on implementation), Null values should be stored as NULL, not -1.
protected  booleansetNullValue(PreparedStatement statement, int index, Object value, CoreField field, int type)
     Stores the 'null' value in the statement if appopriate (the value is null or unset, and the value may indeed be NULL, according to the configuration).
protected  voidsetNumericValue(PreparedStatement statement, int index, Object value, CoreField field, MMObjectNode node)
     Store a numeric value of a field in a prepared statement The method uses the Casting class to convert to the appropriate value. Null values are stored as NULL if possible, otherwise they are stored as -1. Override this method if you want to override this behavior.
Parameters:
  statement - the prepared statement
Parameters:
  index - the index of the field in the prepared statement
Parameters:
  value - the numeric value to store.
protected  ObjectsetStringValue(PreparedStatement statement, int index, Object objectValue, CoreField field, MMObjectNode node)
     Store the text value of a field in a prepared statement. Null values are stored as NULL if possible, otherwise they are stored as an empty string. If the FORCE_ENCODE_TEXT option is set, text is encoded (using the MMBase encoding) to a byte array and stored as a binary stream. Otherwise it uses PreparedStatement.setString(intString) to set the data. Override this method if you use another way to store large texts (i.e.
protected  voidsetValue(PreparedStatement statement, int index, MMObjectNode node, CoreField field)
    
protected  voidsetXMLValue(PreparedStatement statement, int index, Object objectValue, CoreField field, MMObjectNode node)
     This default implementation calls DatabaseStorageManager.setStringValue .
protected  booleanshorten(CoreField field)
     Determine whether a field (such as a large text or a blob) should be shortened or not.
public  intsize(MMObjectBuilder builder)
    
public  intsize()
    
protected  voidstoreBinaryAsFile(MMObjectNode node, CoreField field)
    
protected  booleantablesInheritFields()
     Returns whether tables inherit fields form parent tables.
protected  voidunloadShortedFields(MMObjectNode node, MMObjectBuilder builder)
    
public  voidverify(MMObjectBuilder builder)
     Tests whether a builder and the table present in the database match.

Field Detail
OBJ2TYPE_MAX_SIZE
final public static int OBJ2TYPE_MAX_SIZE(Code)
Max size of the object type cache



activeConnection
protected Connection activeConnection(Code)
The currently active Connection. This member is set by {!link #getActiveConnection()} and unset by DatabaseStorageManager.releaseActiveConnection()



changes
final protected Map<MMObjectNode, String> changes(Code)
Pool of changed nodes in a transaction



factory
protected DatabaseStorageManagerFactory factory(Code)
The factory that created this manager



inTransaction
protected boolean inTransaction(Code)
true if a transaction has been started. This member is for state maitenance and may be true even if the storage does not support transactions



sequenceKeys
final protected static List<Integer> sequenceKeys(Code)



transactionIsolation
protected int transactionIsolation(Code)
The transaction issolation level to use when starting a transaction. This value is retrieved from the factory's Attributes.TRANSACTION_ISOLATION_LEVEL attribute, which is commonly set to the highest (most secure) transaction isolation level available.



typeCache
protected static Cache<Integer, Integer> typeCache(Code)
The cache that contains the last X types of all requested objects
since:
   1.7




Constructor Detail
DatabaseStorageManager
public DatabaseStorageManager()(Code)
Constructor




Method Detail
addToTableNameCache
protected void addToTableNameCache(String name)(Code)



beginTransaction
public void beginTransaction() throws StorageException(Code)



change
public void change(MMObjectNode node) throws StorageException(Code)



change
protected void change(MMObjectNode node, MMObjectBuilder builder) throws StorageException(Code)
Change this node in the specified builder. This method makes it easier to implement relational databses, where you may need to update the node in more than one builder. Call this method for all involved builders if you use a relational database.
Parameters:
  node - The node to change
Parameters:
  builder - the builder to store the node
throws:
  StorageException - if an error occurred during change



change
protected void change(MMObjectNode node, MMObjectBuilder builder, String tableName, Collection<CoreField> changeFields)(Code)



change
public void change(MMObjectBuilder builder) throws StorageException(Code)



change
public void change(CoreField field) throws StorageException(Code)



checkFile
protected File checkFile(File binaryFile, MMObjectNode node, CoreField field)(Code)
Checks whether file is readable and existing. Warns if not. If non-existing it checks older locations. the file to be used, or null if no existing readable file could be found, also no 'legacy' one.



commit
public void commit() throws StorageException(Code)



commitChange
protected void commitChange(MMObjectNode node, String change)(Code)
Commits the change to a node. If the manager is in a transaction (and supports it), the change is stored in a DatabaseStorageManager.changes object (to be committed after the transaction ends). Otherwise it directly commits and broadcasts the changes
Parameters:
  node - the node to register
Parameters:
  change - the type of change: "n": new, "c": commit, "d": delete, "r" : relation changed



convertLegacyBinaryFiles
public int convertLegacyBinaryFiles() throws org.mmbase.storage.search.SearchQueryException, SQLException(Code)
Convert legacy file Number of converted fields. Or -1 if not storing binaries as files



create
public int create(MMObjectNode node) throws StorageException(Code)



create
protected void create(MMObjectNode node, MMObjectBuilder builder) throws StorageException(Code)
This method inserts a new object in a specific builder, and registers the change. This method makes it easier to implement relational databases, where you may need to update the node in more than one builder. Call this method for all involved builders if you use a relational database.
Parameters:
  node - The node to insert. The node already needs to have a (new) number assigned
Parameters:
  builder - the builder to store the node
throws:
  StorageException - if an error occurred during creation



create
protected void create(MMObjectNode node, List<CoreField> createFields, String tablename)(Code)



create
public void create(MMObjectBuilder builder) throws StorageException(Code)



create
public void create() throws StorageException(Code)



create
protected void create(Index index) throws StorageException(Code)
Create an index or a unique constraint.
Parameters:
  index - the index to create



create
public void create(CoreField field) throws StorageException(Code)



createIndex
protected void createIndex(Index index, String tablename)(Code)
Create an index or a unique constraint.
Parameters:
  index - the index to create
Parameters:
  tablename - name of the table



createIndices
protected void createIndices(CoreField field) throws StorageException(Code)
(Re)create all constraints and indices that contain a specific field. You should have an active connection before calling this method.
Parameters:
  field - the field for which to create indices
throws:
  StorageException - when a database error occurs



createKey
public int createKey() throws StorageException(Code)



createSequence
protected void createSequence() throws StorageException(Code)
Creates a means for the database to pre-create keys with increasing numbers. A sequence can be a database routine, a number table, or anything else that can be used to create unique numbers. Keys can be obtained from the sequence by calling DatabaseStorageManager.createKey() .
throws:
  StorageException - when the sequence can not be created



createTable
protected void createTable(MMObjectBuilder builder, List<CoreField> tableFields, String tableName)(Code)



delete
public void delete(MMObjectNode node) throws StorageException(Code)



delete
protected void delete(MMObjectNode node, MMObjectBuilder builder) throws StorageException(Code)
Delete a node from a specific builder This method makes it easier to implement relational databses, where you may need to remove the node in more than one builder. Call this method for all involved builders if you use a relational database.
Parameters:
  node - The node to delete
throws:
  StorageException - if an error occurred during delete



delete
protected void delete(MMObjectNode node, MMObjectBuilder builder, List<CoreField> blobFileField, String tablename)(Code)



delete
public synchronized void delete(MMObjectBuilder builder) throws StorageException(Code)



delete
protected void delete(Index index) throws StorageException(Code)
Drop a constraint or index. You should have an active connection before calling this method.
Parameters:
  index - the index to drop
throws:
  StorageException - when a database error occurs



delete
public void delete(CoreField field) throws StorageException(Code)



deleteIndices
protected void deleteIndices(CoreField field) throws StorageException(Code)
Drop all constraints and indices that contain a specific field. You should have an active connection before calling this method.
Parameters:
  field - the field for which to drop indices
throws:
  StorageException - when a database error occurs



executeUpdate
protected void executeUpdate(String query, MMObjectNode node, List<CoreField> fields) throws SQLException(Code)
Executes an update query for given node and fields. This is wrapped in a function because it is repeatedly called in DatabaseStorageManager.executeUpdateCheckConnection which in turn is called from several spots in this class.
since:
   MMBase-1.7.1



executeUpdateCheckConnection
protected void executeUpdateCheckConnection(String query, MMObjectNode node, List<CoreField> fields) throws SQLException(Code)
Executes an update query for given node and fields. It will close the connections which are no good, which it determines by trying "SELECT 1 FROM " after failure. If that happens, the connection is explicitely closed (in case the driver has not done that), which will render is unusable and at least GenericDataSource will automaticly try to get new ones.
throws:
  SQLException - If something wrong with the query, or the database is down or could not be contacted.
since:
   MMBase-1.7.1



exists
public boolean exists(MMObjectBuilder builder) throws StorageException(Code)



exists
protected synchronized boolean exists(String tableName) throws StorageException(Code)
Queries the database metadata to test whether a given table exists.
Parameters:
  tableName - name of the table to look for
throws:
  StorageException - when the metadata could not be retrieved true if the table exists



exists
public boolean exists() throws StorageException(Code)



exists
protected boolean exists(Index index, String tablename)(Code)
Determines if an index exists. You should have an active connection before calling this method.
Parameters:
  index - the index to test
Parameters:
  tablename - the tablename to test the index against
throws:
  StorageException - when a database error occurs



exists
protected boolean exists(Index index) throws StorageException(Code)
Determines if an index exists. You should have an active connection before calling this method.
Parameters:
  index - the index to test
throws:
  StorageException - when a database error occurs



fillNode
protected void fillNode(MMObjectNode node, ResultSet result, MMObjectBuilder builder) throws StorageException(Code)
Fills a single Node from the resultset of a query. You can use this method to iterate through a query, creating multiple nodes, provided the resultset still contains members (that is, result.isAfterLast returns false)
Parameters:
  node - The MMObjectNode to be filled
Parameters:
  result - the resultset
Parameters:
  builder - the builder to use for creating the node
throws:
  StorageException - if the resultset is exhausted or a database error occurred



getActiveConnection
protected Connection getActiveConnection() throws SQLException(Code)
Obtains an active connection, opening a new one if needed. This method sets and then returns the DatabaseStorageManager.activeConnection member. If an active connection was allready open, and the manager is in a database transaction, that connection is returned instead. Otherwise, the connection is closed before a new one is opened.
throws:
  SQLException - if opening the connection failed



getBinaryFile
protected File getBinaryFile(MMObjectNode node, String fieldName)(Code)
Defines how binary (blob) data files must look like.
Parameters:
  node - the node the binary data belongs to
Parameters:
  fieldName - the name of the binary field The File where to store or read the binary data



getBinaryValue
public byte[] getBinaryValue(MMObjectNode node, CoreField field) throws StorageException(Code)



getBlobFromDatabase
protected Blob getBlobFromDatabase(MMObjectNode node, CoreField field, boolean mayShorten)(Code)
Read a binary (blob) from a field in the database
Parameters:
  node - the node the binary data belongs to
Parameters:
  field - the binary field An InputStream representing the binary data, null if no binary data was stored, or VALUE_SHORTED, if mayShorten



getBlobFromFile
protected Blob getBlobFromFile(MMObjectNode node, CoreField field, boolean mayShorten) throws StorageException(Code)
Read a binary (blob) data file
Parameters:
  node - the node the binary data belongs to
Parameters:
  field - the binary field the byte array containing the binary data, null if no binary data was stored



getBlobValue
public Blob getBlobValue(MMObjectNode node, CoreField field) throws StorageException(Code)



getBlobValue
public Blob getBlobValue(MMObjectNode node, CoreField field, boolean mayShorten) throws StorageException(Code)



getBlobValue
protected Blob getBlobValue(ResultSet result, int index, CoreField field, boolean mayShorten) throws StorageException, SQLException(Code)
Retrieve a large binary object (byte array) for a specified object field. The default method uses ResultSet.getBytes(int) to obtain text. Override this method if you want to optimize retrieving large objects, i.e by using clobs or streams.
Parameters:
  result - the resultset to retrieve the text from
Parameters:
  index - the index of the text in the resultset, or -1 to retireiv from file (blobs).
Parameters:
  field - the (MMBase) fieldtype. This value can be null the retrieved data, null if no binary data was stored
throws:
  SQLException - when a database error occurs
throws:
  StorageException - when data is incompatible or the function is not supported



getBooleanValue
protected Boolean getBooleanValue(ResultSet result, int index, CoreField field) throws StorageException, SQLException(Code)
Retrieve a boolean value for a specified object field. The default method uses ResultSet.getBoolean(int) to obtain the date.
Parameters:
  result - the resultset to retrieve the value from
Parameters:
  index - the index of the value in the resultset
Parameters:
  field - the (MMBase) fieldtype. This value can be null the retrieved Boolean value, null if no text was stored
throws:
  SQLException - when a database error occurs
throws:
  StorageException - when data is incompatible or the function is not supported
since:
   MMBase-1.8



getConstraintDefinition
protected String getConstraintDefinition(CoreField field) throws StorageException(Code)
Creates an index definition string for a field to be passed when creating a table.
Parameters:
  field - the field for which to make the index definition the index definition as a String, or null if no definition is available



getDateTimeValue
protected java.util.Date getDateTimeValue(ResultSet result, int index, CoreField field) throws StorageException, SQLException(Code)
Retrieve a date for a specified object field. The default method uses ResultSet.getTimestamp(int) to obtain the date.
Parameters:
  result - the resultset to retrieve the value from
Parameters:
  index - the index of the value in the resultset
Parameters:
  field - the (MMBase) fieldtype. This value can be null the retrieved java.util.Date value, null if no text was stored
throws:
  SQLException - when a database error occurs
throws:
  StorageException - when data is incompatible or the function is not supported
since:
   MMBase-1.8



getFieldDefinition
protected String getFieldDefinition(CoreField field) throws StorageException(Code)
Creates a fielddefinition, of the format '[fieldname] [fieldtype] NULL' or '[fieldname] [fieldtype] NOT NULL' (depending on whether the field is nullable). The fieldtype is taken from the type mapping in the factory.
Parameters:
  field - the field the typedefiniton as a String
throws:
  StorageException - if the field type cannot be mapped



getFieldList
protected String getFieldList(Index index)(Code)
Returns a comma seperated list of fieldnames for an index.
Parameters:
  index - the index to create it for the field list definition as a String, or null if the index was empty, orif it consists of a composite index and composite indices are not supported.



getFieldTypeDefinition
protected String getFieldTypeDefinition(CoreField field) throws StorageException(Code)
Creates a field type definition, of the format '[fieldtype] NULL' or '[fieldtype] NOT NULL' (depending on whether the field is nullable). The fieldtype is taken from the type mapping in the factory.
since:
   MMBase-1.8
Parameters:
  field - the field the typedefiniton as a String
throws:
  StorageException - if the field type cannot be mapped



getInputStreamValue
public InputStream getInputStreamValue(MMObjectNode node, CoreField field) throws StorageException(Code)



getJDBCtoField
protected int getJDBCtoField(int jdbcType, int mmbaseType)(Code)
Guess the (mmbase) type in storage using the JDBC type. Because a JDBC type can represent more than one mmbase Type, the current type is also passed - if the current type matches, that type is returned, otherwise the method returns the closest matching MMBase type.



getLogStartTime
protected long getLogStartTime()(Code)



getNode
public MMObjectNode getNode(MMObjectBuilder builder, int number) throws StorageException(Code)



getNodeType
public int getNodeType(int number) throws StorageException(Code)



getStringValue
public String getStringValue(MMObjectNode node, CoreField field) throws StorageException(Code)



getStringValue
protected Object getStringValue(ResultSet result, int index, CoreField field, boolean mayShorten) throws StorageException, SQLException(Code)
Retrieve a text for a specified object field. The default method uses ResultSet.getString(int) to obtain text. Override this method if you want to optimize retrieving large texts, i.e by using clobs or streams.
Parameters:
  result - the resultset to retrieve the text from
Parameters:
  index - the index of the text in the resultset
Parameters:
  field - the (MMBase) fieldtype. This value can be null the retrieved text, null if no text was stored
throws:
  SQLException - when a database error occurs
throws:
  StorageException - when data is incompatible or the function is not supported



getValue
public Object getValue(ResultSet result, int index, CoreField field, boolean mayShorten) throws StorageException(Code)
Attempts to return a single field value from the resultset of a query.
Parameters:
  result - the resultset
Parameters:
  index - the index of the field in the resultset
Parameters:
  field - the expected MMBase field type. This can be null
Parameters:
  mayShorten - Whether it would suffice to return only a 'shorted' version of the value. the value
throws:
  StorageException - if the value cannot be retrieved from the resultset



getVersion
public double getVersion()(Code)



getXMLValue
protected Object getXMLValue(ResultSet result, int index, CoreField field, boolean mayShorten) throws StorageException, SQLException(Code)
Retrieve the XML (as a string) for a specified object field. The default method uses ResultSet.getString(int) to obtain text. Unlike Override this method if you want to optimize retrieving large texts, i.e by using clobs or streams.
Parameters:
  result - the resultset to retrieve the xml from
Parameters:
  index - the index of the xml in the resultset
Parameters:
  field - the (MMBase) fieldtype. This value can be null the retrieved xml as text, null if nothing was stored
throws:
  SQLException - when a database error occurs
throws:
  StorageException - when data is incompatible or the function is not supported



init
public void init(StorageManagerFactory factory) throws StorageException(Code)



isPartOfBuilderDefinition
protected boolean isPartOfBuilderDefinition(CoreField field)(Code)
Determines whether the storage should make a field definition in a builder table for a specified field.



isVerified
public boolean isVerified(MMObjectBuilder builder)(Code)
Check if builders are already verified with the database.
Parameters:
  builder - Builder which might be verified true when already verified



logQuery
final protected void logQuery(String query, long startTime)(Code)



refresh
protected void refresh(MMObjectNode node) throws StorageException(Code)
Reloads the data from a node from the database. Use this after a create or change action, so the data in memory is consistent with any data stored in the database.
Parameters:
  node - the node to refresh



releaseActiveConnection
protected void releaseActiveConnection()(Code)
Safely closes the active connection. If a transaction has been started, the connection is not closed.



rollback
public boolean rollback() throws StorageException(Code)



setBinaryValue
protected void setBinaryValue(PreparedStatement statement, int index, Object objectValue, CoreField field, MMObjectNode node) throws StorageException, SQLException(Code)
Store binary data of a field in a prepared statement. This basic implementation uses a binary stream to set the data. Null values are stored as NULL if possible, otherwise they are stored as an empty byte-array. Override this method if you use another way to store binaries (i.e. Blobs).
Parameters:
  statement - the prepared statement
Parameters:
  index - the index of the field in the prepared statement
Parameters:
  objectValue - the data (byte array) to store
Parameters:
  field - the MMBase field, containing meta-information
Parameters:
  node - the node that contains the data. Used to update this node if the database layer makes changesto the data (i.e. creating a default value for a non-null field that had a null value)
throws:
  StorageException - if the data is invalid or missing
throws:
  SQLException - if an error occurred while filling in the fields



setBooleanValue
protected void setBooleanValue(PreparedStatement statement, int index, Object value, CoreField field, MMObjectNode node) throws StorageException, SQLException(Code)
Store a boolean value of a field in a prepared statement. The method uses the Casting class to convert to the appropriate value. Null values are stored as NULL if possible, otherwise they are stored as false Override this method if you use another way to store booleans
Parameters:
  statement - the prepared statement
Parameters:
  index - the index of the field in the prepared statement
Parameters:
  value - the data (boolean) to store
Parameters:
  field - the MMBase field, containing meta-information
Parameters:
  node - the node that contains the data. Used to update this node if the database layer makes changesto the data (i.e. creating a default value for a non-null field that had a null value)
throws:
  StorageException - if the data is invalid or missing
throws:
  SQLException - if an error occurred while filling in the fields
since:
   MMBase-1.8



setDateTimeValue
protected void setDateTimeValue(PreparedStatement statement, int index, Object value, CoreField field, MMObjectNode node) throws StorageException, SQLException(Code)
Store a Date value of a field in a prepared statement. The method uses the Casting class to convert to the appropriate value. Null values are stored as NULL if possible, otherwise they are stored as the date 31/12/1969 23:59:59 GMT (-1) TODO: I think that is -1000, not -1. Override this method if you use another way to store dates
Parameters:
  statement - the prepared statement
Parameters:
  index - the index of the field in the prepared statement
Parameters:
  value - the data (date) to store
Parameters:
  field - the MMBase field, containing meta-information
Parameters:
  node - the node that contains the data. Used to update this node if the database layer makes changesto the data (i.e. creating a default value for a non-null field that had a null value)
throws:
  StorageException - if the data is invalid or missing
throws:
  SQLException - if an error occurred while filling in the fields
since:
   MMBase-1.8



setListValue
protected void setListValue(PreparedStatement statement, int index, Object value, CoreField field, MMObjectNode node) throws StorageException, SQLException(Code)
Store a List value of a field in a prepared statement. The method uses the Casting class to convert to the appropriate value. Null values are stored as NULL if possible, otherwise they are stored as an empty list. Override this method if you use another way to store lists
Parameters:
  statement - the prepared statement
Parameters:
  index - the index of the field in the prepared statement
Parameters:
  value - the data (List) to store
Parameters:
  field - the MMBase field, containing meta-information. This value can be null
Parameters:
  node - the node that contains the data. Used to update this node if the database layer makes changesto the data (i.e. creating a default value for a non-null field that had a null value)
throws:
  StorageException - if the data is invalid or missing
throws:
  SQLException - if an error occurred while filling in the fields
since:
   MMBase-1.8



setNodeValue
protected void setNodeValue(PreparedStatement statement, int index, Object nodeValue, CoreField field, MMObjectNode node) throws StorageException, SQLException(Code)
Store a node value of a field in a prepared statement Nodes are stored in the database as numeric values. Since a node value can be a (referential) key (depending on implementation), Null values should be stored as NULL, not -1. If a field cannot be null when a value is not given, an exception is thrown. Override this method if you want to override this behavior.
Parameters:
  statement - the prepared statement
Parameters:
  index - the index of the field in the prepared statement
Parameters:
  nodeValue - the node to store
Parameters:
  field - the MMBase field, containing meta-information
Parameters:
  node - the node that contains the data.
throws:
  StorageException - if the data is invalid or missing
throws:
  SQLException - if an error occurred while filling in the fields



setNullValue
protected boolean setNullValue(PreparedStatement statement, int index, Object value, CoreField field, int type) throws StorageException, SQLException(Code)
Stores the 'null' value in the statement if appopriate (the value is null or unset, and the value may indeed be NULL, according to the configuration). If the value is null or unset, but the value may not be NULL, then -1 is stored.
Parameters:
  statement - the prepared statement
Parameters:
  index - the index of the field in the prepared statement
Parameters:
  value - the numeric value to store, which will be checked for null.
Parameters:
  field - the MMBase field, containing meta-information
throws:
  StorageException - if the data is invalid or missing
throws:
  SQLException - if an error occurred while filling in the fields true if a null value was set, false otherwise
since:
   MMBase-1.7.1



setNumericValue
protected void setNumericValue(PreparedStatement statement, int index, Object value, CoreField field, MMObjectNode node) throws StorageException, SQLException(Code)
Store a numeric value of a field in a prepared statement The method uses the Casting class to convert to the appropriate value. Null values are stored as NULL if possible, otherwise they are stored as -1. Override this method if you want to override this behavior.
Parameters:
  statement - the prepared statement
Parameters:
  index - the index of the field in the prepared statement
Parameters:
  value - the numeric value to store. This may be a String, MMObjectNode, Numeric, or other value - themethod will convert it to the appropriate value.
Parameters:
  field - the MMBase field, containing meta-information
Parameters:
  node - the node that contains the data. Used to update this node if the database layer makes changesto the data (i.e. creating a default value for a non-null field that had a null value)
throws:
  StorageException - if the data is invalid or missing
throws:
  SQLException - if an error occurred while filling in the fields



setStringValue
protected Object setStringValue(PreparedStatement statement, int index, Object objectValue, CoreField field, MMObjectNode node) throws StorageException, SQLException(Code)
Store the text value of a field in a prepared statement. Null values are stored as NULL if possible, otherwise they are stored as an empty string. If the FORCE_ENCODE_TEXT option is set, text is encoded (using the MMBase encoding) to a byte array and stored as a binary stream. Otherwise it uses PreparedStatement.setString(intString) to set the data. Override this method if you use another way to store large texts (i.e. Clobs).
Parameters:
  statement - the prepared statement
Parameters:
  index - the index of the field in the prepared statement
Parameters:
  objectValue - the text to store
Parameters:
  field - the MMBase field, containing meta-information
Parameters:
  node - the node that contains the data.
throws:
  StorageException - if the data is invalid or missing
throws:
  SQLException - if an error occurred while filling in the fields



setValue
protected void setValue(PreparedStatement statement, int index, MMObjectNode node, CoreField field) throws StorageException, SQLException(Code)
Store the value of a field in a prepared statement
Parameters:
  statement - the prepared statement
Parameters:
  index - the index of the field in the prepared statement
Parameters:
  node - the node from which to retrieve the value
Parameters:
  field - the MMBase field, containing meta-information
throws:
  StorageException - if the fieldtype is invalid, or data is invalid or missing
throws:
  SQLException - if an error occurred while filling in the fields



setXMLValue
protected void setXMLValue(PreparedStatement statement, int index, Object objectValue, CoreField field, MMObjectNode node) throws StorageException, SQLException(Code)
This default implementation calls DatabaseStorageManager.setStringValue . Override this method if you want to override this behavior.
since:
   MMBase-1.7.1



shorten
protected boolean shorten(CoreField field)(Code)
Determine whether a field (such as a large text or a blob) should be shortened or not. A 'shortened' field contains a placeholder text ('$SHORTED') to indicate that the field is expected to be of large size and should be retrieved by an explicit call to DatabaseStorageManager.getStringValue(MMObjectNode,CoreField) or. DatabaseStorageManager.getBinaryValue(MMObjectNode,CoreField) . The default implementation returns true for binaries, and false for other types. Override this method if you want to be able to change the placeholder strategy.
Parameters:
  field - the (MMBase) fieldtype true if the field should be shortened
throws:
  SQLException - when a database error occurs
throws:
  StorageException - when data is incompatible or the function is not supported



size
public int size(MMObjectBuilder builder) throws StorageException(Code)



size
public int size() throws StorageException(Code)



storeBinaryAsFile
protected void storeBinaryAsFile(MMObjectNode node, CoreField field) throws StorageException(Code)
Store a binary (blob) data file
Parameters:
  node - the node the binary data belongs to
Parameters:
  field - the binary field



tablesInheritFields
protected boolean tablesInheritFields()(Code)
Returns whether tables inherit fields form parent tables. this determines whether fields that are inherited in mmbase builders are redefined in the database tables.



unloadShortedFields
protected void unloadShortedFields(MMObjectNode node, MMObjectBuilder builder)(Code)



verify
public void verify(MMObjectBuilder builder) throws StorageException(Code)
Tests whether a builder and the table present in the database match.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.