| com.jcorporate.expresso.core.db.DBException com.jcorporate.expresso.core.dataobjects.DataException com.jcorporate.expresso.core.dataobjects.jdbc.JDBCUtil
JDBCUtil | public class JDBCUtil extends DataException (Code) | | This class provides utility functions that are common across the jdbc.*
package classes. This class is normally not accessed except through other
classes in the jdbc package.
author: Michael Rimov since: Expresso 5.0 |
Constructor Summary | |
protected | JDBCUtil() |
Method Summary | |
public void | buildStoreProcedureCallableStatement(JDBCDataObject criteria, CallableStatement myCallableStatement) Build and return a FastStringBuffer ring consisting of an SQL 'where' clause
using the current field values as criteria for the search. | public String | buildWhereClause(JDBCDataObject criteria, boolean useAllFields) Build and return a string consisting of an SQL 'where' clause
using the current field values as criteria for the search. | public FastStringBuffer | buildWhereClauseBuffer(JDBCDataObject criteria, boolean useAllFields, FastStringBuffer allocatedBuffer) Build and return a FastStringBuffer ring consisting of an SQL 'where' clause
using the current field values as criteria for the search. | public boolean | containsWildCards(JDBCDataObject ownerObject, String fieldValue) See if this field value contains wild cards (e.g. | public String | formatDateTime(DataObject theObject, String fieldName) Given the value of a date/time or date/time field, return the value formatted
as appropriate for the current DBMS. | public String | formatDateTime(DataObject theObject, String fieldName, boolean surroundWithQuotes) Given the value of a date/time or datetime field, return the value formatted
as appropriate for the current DBMS. | protected DateReturnFormat | formatDateTimeInternal(DataObject theObject, String fieldName) This class combines the old getFieldDate() with quoteIfNeeded() to format
the Date-Time fields appropriately for storage. | public java.util.Date | getDateField(DataObject theObject, String fieldName) | public static JDBCUtil | getInstance() | protected SimpleDateFormat | getSimpleDateFormat(String pattern) Get a SimpleDateFormat object that is cached. | public String | makeLimitationStub(DBConnection theConnection, DataObject theObj) Creates the limitation syntax optimisation stub
to embed inside the SQL command that performs
search and retrieve.
This method takes the limitation syntax string
and performs a string replacement on the following
tokens
- %offset%
the number of rows in the ResultSet to skip
before reading the data.
- %maxrecord%
the maximum number of rows to read from the ResultSet .
Also known as the rowlength.
- %endrecord%
the last record of in the ResultSet that the
search and retrieved should retrieve. | public String | quoteIfNeeded(JDBCDataObject targetObject, String fieldName, String rangeString) Return the value of this field, placing double quotes around it if the
field's datatype requires it. |
DATETIME_FORMAT | final public static String DATETIME_FORMAT(Code) | | |
JDBCUtil | protected JDBCUtil()(Code) | | |
buildStoreProcedureCallableStatement | public void buildStoreProcedureCallableStatement(JDBCDataObject criteria, CallableStatement myCallableStatement) throws DataException(Code) | | Build and return a FastStringBuffer ring consisting of an SQL 'where' clause
using the current field values as criteria for the search. See
setCustomWhereClause for information on specifying a more complex where clause.
Parameters: criteria - the JDBCDataObject to build from Parameters: useAllFields - True if all fields are to be used,false for only key fields Parameters: allocatedBuffer - - An already allocated FastStringBuffer to fill out.This allows for compatability with, for example, object pools. A FastStringBuffer containing the "where" clause for the SQL statement throws: DataException - upon error |
buildWhereClause | public String buildWhereClause(JDBCDataObject criteria, boolean useAllFields) throws DataException(Code) | | Build and return a string consisting of an SQL 'where' clause
using the current field values as criteria for the search. See
setCustomWhereClause for information on specifying a more complex where clause.
Parameters: criteria - the JDBCDataObject to build from Parameters: useAllFields - True if all fields are to be used,false for only key fields The where clause to use in a query. |
buildWhereClauseBuffer | public FastStringBuffer buildWhereClauseBuffer(JDBCDataObject criteria, boolean useAllFields, FastStringBuffer allocatedBuffer) throws DataException(Code) | | Build and return a FastStringBuffer ring consisting of an SQL 'where' clause
using the current field values as criteria for the search. See
setCustomWhereClause for information on specifying a more complex where clause.
Parameters: criteria - the JDBCDataObject to build from Parameters: useAllFields - True if all fields are to be used,false for only key fields Parameters: allocatedBuffer - - An already allocated FastStringBuffer to fill out.This allows for compatability with, for example, object pools. A FastStringBuffer containing the "where" clause for the SQL statement throws: DataException - upon error |
containsWildCards | public boolean containsWildCards(JDBCDataObject ownerObject, String fieldValue) throws DataException(Code) | | See if this field value contains wild cards (e.g. pattern matching
criteria for the database). The wild cards can be configured via the
properties file.
Parameters: fieldValue - The field value to check for wild cards Parameters: ownerObject - the obejct to query for metadata True if the string does contain wild cards, False if it does not |
formatDateTime | public String formatDateTime(DataObject theObject, String fieldName) throws DataException(Code) | | Given the value of a date/time or date/time field, return the value formatted
as appropriate for the current DBMS. Can be configured using property
file values.
Parameters: fieldName - java.lang.String The value for the date/time field. Parameters: theObject - the DataObject that the date field is comingfrom. java.lang.String The formatted date time, ready for use in the DBMS |
formatDateTime | public String formatDateTime(DataObject theObject, String fieldName, boolean surroundWithQuotes) throws DataException(Code) | | Given the value of a date/time or datetime field, return the value formatted
as appropriate for the current DBMS. Can be configured using expresso-config
file values.
Parameters: fieldName - java.lang.String The value for the date/time field. Parameters: theObject - the DataObject that the date field is comingfrom. Parameters: surroundWithQuotes - set to true if you want the returned valueto be surrounded with single quotes, such as for a standard JDBC SELECT statement.Use false if you want to use it, for example, in a PreparedStatement java.lang.String The formatted date time, ready for use in the DBMS |
formatDateTimeInternal | protected DateReturnFormat formatDateTimeInternal(DataObject theObject, String fieldName) throws DataException(Code) | | This class combines the old getFieldDate() with quoteIfNeeded() to format
the Date-Time fields appropriately for storage. This probably could use
some serious optimization since it looks like at first glance it does
the same operation twice. Any volunteers? :)
Parameters: theObject - The object that contains the data to froatm Parameters: fieldName - the name of the field to format a DateReturnFormat object. throws: DataException - upon error |
getDateField | public java.util.Date getDateField(DataObject theObject, String fieldName) throws DataException(Code) | | Helper function that helps convert any string values from the database's
format
Parameters: theObject - the source data object Parameters: fieldName - the name of the field java.util.Date throws: DataException - upon error (possibly conversion error) |
getSimpleDateFormat | protected SimpleDateFormat getSimpleDateFormat(String pattern)(Code) | | Get a SimpleDateFormat object that is cached. Make sure you have
dateConvertFormatMap already locked before calling this function or you'll
have a race condition.
Parameters: pattern - the format pattern to look up an instantiated SimpleDateFormat object. SimpleDateFormat is NOTthreadsafe, so make sure you do your parsing while still in the synchronizedblock. Perhaps in the future a keyed Object pool will be better. |
makeLimitationStub | public String makeLimitationStub(DBConnection theConnection, DataObject theObj)(Code) | | Creates the limitation syntax optimisation stub
to embed inside the SQL command that performs
search and retrieve.
This method takes the limitation syntax string
and performs a string replacement on the following
tokens
- %offset%
the number of rows in the ResultSet to skip
before reading the data.
- %maxrecord%
the maximum number of rows to read from the ResultSet .
Also known as the rowlength.
- %endrecord%
the last record of in the ResultSet that the
search and retrieved should retrieve. The end record number
is equal to ( %offset% + %maxrecord% - 1 )
author Peter Pilgrim, Thu Jun 21 10:30:59 BST 2001
Parameters: theConnection - the db connection to make this stub from Parameters: theObj - the DataObject to query for the limitation stub the limitation syntax stub string |
quoteIfNeeded | public String quoteIfNeeded(JDBCDataObject targetObject, String fieldName, String rangeString) throws DataException(Code) | | Return the value of this field, placing double quotes around it if the
field's datatype requires it.
Parameters: fieldName - The name of the field to be used Parameters: rangeString - the appropriately formatted string Parameters: targetObject - the JDBCDataObject to query for metadata A string, quoted if necessary, to be used in building an SQL statement throws: DataException - If there is no such field or it's value cannot bedetermined |
|
|