com.sibvisions.rad.persist.jdbc
Class DBAccess

java.lang.Object
  extended by com.sibvisions.rad.persist.jdbc.DBAccess
All Implemented Interfaces:
IDBAccess
Direct Known Subclasses:
DB2DBAccess, DerbyDBAccess, HSQLDBAccess, MSSQLDBAccess, MySQLDBAccess, OracleDBAccess, PostgreSQLDBAccess

public class DBAccess
extends Object
implements IDBAccess

The DBAccess is the implementation for most used SQL databases.
Standard ANSI SQL Databases are anyways supported.
Its used to read/write data between the storage and the DataBook/DataPage. It has database type specific implementations.


Example:

 
 DBAccess dba = new DBAccess();
 
 // set connect properties
 dba.setDriver("org.hsqldb.jdbcDriver");
 dba.setUrl("jdbc:hsqldb:file:testdbs/test/testdb");
 dba.setUsername("sa");
 dba.setPassword("");
 
 Properties pDBProperties = new Properties();
 pDBProperties.put("shutdown", true);
 dba.setDBProperties(pDBProperties);
 
 // open
 dba.open();
 
 To get Database independent DBAccess, it is better to use:
 
 DBAccess dba = DBAccess.getDBAccess("jdbc:hsqldb:file:testdbs/test/testdb");
 
 // insert data into test table
 PreparedStatement psPreparedStatement = dba.getPreparedStatement(
                     "insert into test (id, name) values(?,?)", false);
 psPreparedStatement.setInt(1, 1);
 psPreparedStatement.setString(2, "projectX");
 dba.executeUpdate(psPreparedStatement);
 
 // select data from test table
 psPreparedStatement = dba.getPreparedStatement("select * from test", false);
 ResultSet rs = dba.executeQuery(psPreparedStatement);
 
 while (rs.next())
 {
    System.out.println(rs.getInt("id") + "," + rs.getString("name"));
 }
 
 

See Also:
IDBAccess, RemoteDataBook

Field Summary
protected static ILogger logger
          The logger for protocol the performance.
static int LONGNVARCHAR
          A jdbc VARCHAR DB column data type constant.
static int NCHAR
          A jdbc VARCHAR DB column data type constant.
static int NCLOB
          A jdbc BLOB DB column data type constant.
static int NVARCHAR
          A jdbc VARCHAR DB column data type constant.
static int SQLXML
          A jdbc XML DB column data type constant.
 
Constructor Summary
DBAccess()
          Constructs a new DBAccess Object.
 
Method Summary
 void close()
          Closes the database Connection and releases all memory.
 void commit()
          Commits the DB transaction.
 void delete(String pWritebackTable, MetaData pMetaData, Object[] pDelete)
          Deletes the specified row.
 Object executeFunction(String pStatement, Object... pParameters)
          Executes a DB function with the specified parameters and return the result.
 void executeProcedure(String pStatement, Object... pParameters)
          Executes a DB procedure with the specified parameters.
 int executeUpdate(PreparedStatement pSqlStatement)
          Calls executesUpdate() for specified PreparedStatement and returns the number of updated rows.
 List<Object[]> fetch(MetaData pMetaData, String pBeforeQueryColumns, String[] pQueryColumns, String pFromClause, ICondition pFilter, String pLastWhereCondition, String pAfterWhereClause, SortDefinition pSort, int pFromRow, int pMinimumRowCount)
          Returns the List of fetched rows (as List of Object[]) for the specified query tables and parameters.
protected  String getAutomaticLinkColName(ForeignKey pForeignKey)
          Returns the automatic link column name for the specified ForeignKey and FK Column in the master table.
 ColumnMetaData[] getColumnMetaData(String pFromClause, String[] pQueryColumns, String pBeforeQueryColumns, String pWhereClause, String pAfterWhereClause, String pWritebackTable, String[] pWritebackColumns, String[] pMetaDataContext)
          Returns the meta data for the specified query, and initials all columns.
 Connection getConnection()
          Returns the SQL Conncetion to the database.
 String getDatabaseSpecificLockStatement(String pWritebackTable, MetaData pMetaData, ICondition pPKFilter)
          Returns the database specific statement to lock the specified row in the database.
static DBAccess getDBAccess(String pJdbcUrl)
          Gets the suitable DBAcces for the given JdbcUrl.
 Properties getDBProperties()
          Returns the DB specific initial parameters for the Connection creation.
 String getDBProperty(String pName)
          Gets the value for a specific database property.
 String getDriver()
          Gets the database driver name as String.
 List<ForeignKey> getFKs(String pCatalog, String pSchema, String pTable)
          Returns all Foreign Keys for the specified table.
protected  String getFromClause(String pWritebackTable, List<ForeignKey> auForeignKeys)
          It creates and returns a from clause with joins over all foreign tables.
 int getMaxTime()
          Returns the maximum time in miliseconds to use, to try to fetch all rows. reduce open cursors, and increase performance.
 String getPassword()
          Sets the password to use for the connection to the database.
 String[] getPK(String pCatalog, String pSchema, String pTable)
          It's gets all Primary Key columns and return it as String[].
 PreparedStatement getPreparedStatement(String pSqlStatement, boolean pReturnKey)
          Return a PreparedStatement for the given SQL statement.
protected  String[] getQueryColumns(String pWritebackTable, List<ForeignKey> auForeignKeys, String[] auWritebackColumns)
          It creates and returns the query columns, with all write back columns and includs the columns for the LinkReferences (automatic link celleditors).
 String getSelectStatement(ICondition pFilter, String sFromClause, String[] saQueryColumns, String sBeforeQueryColumns, String sWhereClause, String sAfterWhereClause, MetaData pMetaData)
          It initialize the select for a specified storage unit and return the SELECT statement.
 List<String[]> getUKs(String pCatalog, String pSchema, String pTable)
          It's gets all columns for each Unique Key and return it.
 String getUrl()
          Gets the jdbc url String for this database.
 String getUsername()
          Gets the user name to connect with.
 String getWHEREClause(ICondition pFilter, MetaData pMetaData, boolean pUsePrefix)
          Returns the WHERE clause for a UPDATE, DELETE or SELECT statement specified with a Filter.
 Object[] insert(String pWritebackTable, MetaData pMetaData, Object[] pNewDataRow)
          Returns the newly inserted row from the write back table.
 Object[] insertAnsiSQL(String pWritebackTable, String pInsertStatement, MetaData pMetaData, Object[] pNewDataRow, String pDummyColumn)
          Returns the newly inserted row from a Ansi SQL Database.
 Object[] insertDatabaseSpecific(String pWritebackTable, String pInsertStatement, MetaData pMetaData, Object[] pNewDataRow, String pDummyColumn)
          Returns the newly inserted row from an Database specific insert statement.
 boolean isOpen()
          Returns true, if the database is still open.
 void lockRow(String pWritebackTable, MetaData pMetaData, ICondition pPKFilter)
          It locks the specified row in the storage.
 void open()
          It opens the database and stores the Connection object.
 String quote(Object pObject)
          Quotes an Object.
static void registerDBAccessClass(String pJdbcUrlPrefix, Class<? extends DBAccess> pClass)
          Registers the Class for the jdbc url prefix.
 void rollback()
          Rollback the DB transaction.
protected  int setColumnsToStore(PreparedStatement pInsert, ColumnMetaData[] pColumnMetaData, int[] iaWriteables, Object[] pNew, Object[] pOld)
          Sets the values of all changed columns to store from the value Object[]s into the PreparedStatement and returns the last used parameter index.
 void setDBProperties(Properties pProperties)
          Sets DB specific initial parameters for the Connection creation.
 void setDBProperty(String pName, String pValue)
          Sets a specific database property.
 void setDriver(String pDriver)
          Sets the database driver name as String.
protected  void setFilterParameter(int iStartParameterIndex, PreparedStatement pStatement, ICondition pFilter)
          Sets all Filter parameter values into the PreparedStatement.
 void setMaxTime(int pMaxTime)
          Sets the maximum time in miliseconds to use, to try to fetch all rows. reduce open cursors, and increase performance.
 void setPassword(String pPassword)
          Sets the password to use for the connection to the database.
 void setQueryTimeOut(int pQueryTimeOut)
          Sets the query time out.
 void setUrl(String pUrl)
          Sets the url String for this database.
 void setUsername(String pUsername)
          Sets the user name to connect with.
 boolean supportsGetGeneratedKeys()
          Returns if this Database specific supports generated keys.
 String toString()
          
 Object[] update(String pWritebackTable, MetaData pMetaData, Object[] pOld, Object[] pNew)
          Return the updated row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NCHAR

public static final int NCHAR
A jdbc VARCHAR DB column data type constant.

See Also:
Constant Field Values

NVARCHAR

public static final int NVARCHAR
A jdbc VARCHAR DB column data type constant.

See Also:
Constant Field Values

LONGNVARCHAR

public static final int LONGNVARCHAR
A jdbc VARCHAR DB column data type constant.

See Also:
Constant Field Values

SQLXML

public static final int SQLXML
A jdbc XML DB column data type constant.

See Also:
Constant Field Values

NCLOB

public static final int NCLOB
A jdbc BLOB DB column data type constant.

See Also:
Constant Field Values

logger

protected static ILogger logger
The logger for protocol the performance.

Constructor Detail

DBAccess

public DBAccess()
Constructs a new DBAccess Object.

Method Detail

getDBAccess

public static DBAccess getDBAccess(String pJdbcUrl)
                            throws InstantiationException,
                                   IllegalAccessException
Gets the suitable DBAcces for the given JdbcUrl.

Parameters:
pJdbcUrl - the JdbcUrl
Returns:
the suitable DBAccess.
Throws:
IllegalAccessException - if the DBAccess instance is not allowed.
InstantiationException - if the DBAccess instance cannot be created.

registerDBAccessClass

public static void registerDBAccessClass(String pJdbcUrlPrefix,
                                         Class<? extends DBAccess> pClass)
Registers the Class for the jdbc url prefix.

Parameters:
pJdbcUrlPrefix - the jdbc url prefix.
pClass - the Class.

getFromClause

protected String getFromClause(String pWritebackTable,
                               List<ForeignKey> auForeignKeys)
                        throws DataSourceException
It creates and returns a from clause with joins over all foreign tables.

Parameters:
pWritebackTable - the write back table to use
auForeignKeys - the ForeignKey array to use
Returns:
a from clause with joins over all foreign tables.
Throws:
DataSourceException - if an error occur in determining the from clause and query columns.

getAutomaticLinkColName

protected String getAutomaticLinkColName(ForeignKey pForeignKey)
Returns the automatic link column name for the specified ForeignKey and FK Column in the master table.

Parameters:
pForeignKey - the ForeignKEy to use.
Returns:
the automatc link column name for the specified ForeignKey and FK Column in the master table.

getQueryColumns

protected String[] getQueryColumns(String pWritebackTable,
                                   List<ForeignKey> auForeignKeys,
                                   String[] auWritebackColumns)
                            throws DataSourceException
It creates and returns the query columns, with all write back columns and includs the columns for the LinkReferences (automatic link celleditors).

Parameters:
pWritebackTable - the write back table to use
auForeignKeys - the ForeignKey array to use
auWritebackColumns - the write back table columns to use.
Returns:
the query columns, with all write back columns and includs the columns for the LinkReferences (automatic link celleditors).
Throws:
DataSourceException - if an error occur in determining the from clause and query columns.

getUKs

public List<String[]> getUKs(String pCatalog,
                             String pSchema,
                             String pTable)
                      throws DataSourceException
It's gets all columns for each Unique Key and return it.

Parameters:
pCatalog - the catalog to use
pSchema - the schema to use
pTable - the table to use
Returns:
all columns for each Unique Key.
Throws:
DataSourceException - if an error occur during UK search process.

getPK

public String[] getPK(String pCatalog,
                      String pSchema,
                      String pTable)
               throws DataSourceException
It's gets all Primary Key columns and return it as String[].

Parameters:
pCatalog - the catalog to use
pSchema - the schema to use
pTable - the table to use
Returns:
all Primary Key columns and return it as String[].
Throws:
DataSourceException - if an error occur during PK search process.

getFKs

public List<ForeignKey> getFKs(String pCatalog,
                               String pSchema,
                               String pTable)
                        throws DataSourceException
Returns all Foreign Keys for the specified table.

Parameters:
pCatalog - the catalog to use
pSchema - the schema to use
pTable - the table to use as base table.
Returns:
all Foreign Keys for the specified table.
Throws:
DataSourceException - if an error occur in determining the ForeignKeys.

fetch

public List<Object[]> fetch(MetaData pMetaData,
                            String pBeforeQueryColumns,
                            String[] pQueryColumns,
                            String pFromClause,
                            ICondition pFilter,
                            String pLastWhereCondition,
                            String pAfterWhereClause,
                            SortDefinition pSort,
                            int pFromRow,
                            int pMinimumRowCount)
                     throws DataSourceException
Returns the List of fetched rows (as List of Object[]) for the specified query tables and parameters. It fetch's the the rows from pFromRow row index a minimum amount of pMinimumRowCount rows. Implementations should fetch as much rows as possible in a proper amount of time, to get less requests from the client model to the server IDBAccess. Implementation can cache the select cursor and reuse it for the next fetch operation, but they should take care, that's a state less call and in a fall over case it maybe loose on the fail over system the cursor.

Specified by:
fetch in interface IDBAccess
Parameters:
pMetaData - the MetaDataColumn array to use.
pBeforeQueryColumns - the before query columns
pQueryColumns - the query columns
pFromClause - the from clause with query tables and join definitions
pFilter - the filter to use
pLastWhereCondition - the last where condition in query
pAfterWhereClause - the after where clause in query
pSort - the sort order to use
pFromRow - the row index from to fetch
pMinimumRowCount - the minimum count row to fetch
Returns:
the List of fetched rows (as List of Object[]) for the specified query tables and parameters.
Throws:
DataSourceException - if the fetch fails.

lockRow

public void lockRow(String pWritebackTable,
                    MetaData pMetaData,
                    ICondition pPKFilter)
             throws DataSourceException
It locks the specified row in the storage.

Specified by:
lockRow in interface IDBAccess
Parameters:
pWritebackTable - the storage unit to use
pMetaData - the MetaDataColumn array to use.
pPKFilter - the PrimaryKey in as an ICondition to identify the row to lock
Throws:
DataSourceException - if an Exception occur during interacting with the storage

insert

public Object[] insert(String pWritebackTable,
                       MetaData pMetaData,
                       Object[] pNewDataRow)
                throws DataSourceException
Returns the newly inserted row from the write back table.

Specified by:
insert in interface IDBAccess
Parameters:
pWritebackTable - the write back table to use.
pMetaData - the meta data to use.
pNewDataRow - the new values Object[] to insert.
Returns:
the newly inserted row as Object[] from the write back table.
Throws:
DataSourceException - if an Exception occur during insert the row to the table

update

public Object[] update(String pWritebackTable,
                       MetaData pMetaData,
                       Object[] pOld,
                       Object[] pNew)
                throws DataSourceException
Return the updated row.

Specified by:
update in interface IDBAccess
Parameters:
pWritebackTable - the write back table to use.
pMetaData - the meta data to use.
pOld - the old values of the row
pNew - the new values of the row
Returns:
the updated row.
Throws:
DataSourceException - if an Exception occur during update.

delete

public void delete(String pWritebackTable,
                   MetaData pMetaData,
                   Object[] pDelete)
            throws DataSourceException
Deletes the specified row.

Specified by:
delete in interface IDBAccess
Parameters:
pWritebackTable - the write back table to use.
pMetaData - the meta data to use.
pDelete - the row to delete.
Throws:
DataSourceException - if an Exception occur during delete.

toString

public String toString()

Overrides:
toString in class Object

open

public void open()
          throws DataSourceException
It opens the database and stores the Connection object.

Throws:
DataSourceException - if the database couldn't opened

isOpen

public boolean isOpen()
               throws DataSourceException
Returns true, if the database is still open.

Returns:
true, if the database is still open.
Throws:
DataSourceException - if isClosed() on the DB Connection throws an Exception

close

public void close()
           throws DataSourceException
Closes the database Connection and releases all memory.

Throws:
DataSourceException - if database couldn't closed.

rollback

public void rollback()
              throws DataSourceException
Rollback the DB transaction.

Throws:
DataSourceException - if the transaction couldn't rollback

commit

public void commit()
            throws DataSourceException
Commits the DB transaction.

Throws:
DataSourceException - if the transaction couldn't commit

setQueryTimeOut

public void setQueryTimeOut(int pQueryTimeOut)
Sets the query time out.

Parameters:
pQueryTimeOut - the timeout in miliseconds

getConnection

public Connection getConnection()
Returns the SQL Conncetion to the database.

Returns:
the SQL Conncetion to the database.

getDriver

public String getDriver()
Gets the database driver name as String.

Returns:
pDriverName the database driver name

setDriver

public void setDriver(String pDriver)
Sets the database driver name as String.

Parameters:
pDriver - the database driver name

getUrl

public String getUrl()
Gets the jdbc url String for this database.

Returns:
the jdbc url String.

setUrl

public void setUrl(String pUrl)
Sets the url String for this database.

Parameters:
pUrl - the jdbc url String.

getUsername

public String getUsername()
Gets the user name to connect with.

Returns:
pUser the user name

setUsername

public void setUsername(String pUsername)
Sets the user name to connect with.

Parameters:
pUsername - the user name

getPassword

public String getPassword()
Sets the password to use for the connection to the database.

Returns:
pPassword the password to use for the database

setPassword

public void setPassword(String pPassword)
Sets the password to use for the connection to the database.

Parameters:
pPassword - the password to use for the database

setDBProperty

public void setDBProperty(String pName,
                          String pValue)
Sets a specific database property.

Parameters:
pName - the property name
pValue - th value

getDBProperty

public String getDBProperty(String pName)
Gets the value for a specific database property.

Parameters:
pName - the property name
Returns:
the value or null if the property was not found

setDBProperties

public void setDBProperties(Properties pProperties)
Sets DB specific initial parameters for the Connection creation.

Parameters:
pProperties - DB specific initial parameters

getDBProperties

public Properties getDBProperties()
Returns the DB specific initial parameters for the Connection creation.

Returns:
the DB specific initial parameters for the Connection creation.

getMaxTime

public int getMaxTime()
Returns the maximum time in miliseconds to use, to try to fetch all rows. reduce open cursors, and increase performance.

Returns:
the iMaxTime.

setMaxTime

public void setMaxTime(int pMaxTime)
Sets the maximum time in miliseconds to use, to try to fetch all rows. reduce open cursors, and increase performance.

Parameters:
pMaxTime - the iMaxTime to set

quote

public String quote(Object pObject)
Quotes an Object.

Parameters:
pObject - the object to quote.
Returns:
the quoted object.

executeProcedure

public void executeProcedure(String pStatement,
                             Object... pParameters)
                      throws DataSourceException
Executes a DB procedure with the specified parameters.

Parameters:
pStatement - the procedure (option with package) name.
pParameters - the parameters to use with the correct and corresponding java type.
Throws:
DataSourceException - if the call failed.

executeFunction

public Object executeFunction(String pStatement,
                              Object... pParameters)
                       throws DataSourceException
Executes a DB function with the specified parameters and return the result.

Parameters:
pStatement - the procedure (option with package) name.
pParameters - the parameters to use with the correct and corresponding java type.
Returns:
the result of the DB function call.
Throws:
DataSourceException - if the call failed.

getPreparedStatement

public PreparedStatement getPreparedStatement(String pSqlStatement,
                                              boolean pReturnKey)
                                       throws DataSourceException
Return a PreparedStatement for the given SQL statement.

Parameters:
pSqlStatement - the SQL statement to prepare
pReturnKey - if the generated key in insert statements should returned
Returns:
a PreparedStatement for the given SQL statement.
Throws:
DataSourceException - if the statement couldn't prepared.

executeUpdate

public int executeUpdate(PreparedStatement pSqlStatement)
                  throws DataSourceException
Calls executesUpdate() for specified PreparedStatement and returns the number of updated rows.

Parameters:
pSqlStatement - the PreparedStatement to use
Returns:
number of updated rows.
Throws:
DataSourceException - if the statement couldn't updated.

getSelectStatement

public String getSelectStatement(ICondition pFilter,
                                 String sFromClause,
                                 String[] saQueryColumns,
                                 String sBeforeQueryColumns,
                                 String sWhereClause,
                                 String sAfterWhereClause,
                                 MetaData pMetaData)
                          throws DataSourceException
It initialize the select for a specified storage unit and return the SELECT statement.
It doesn't add the ORDER BY clause.

Parameters:
pFilter - the Filter to use
sFromClause - the list of query tables to use in the SELECT statement.
saQueryColumns - the list of query columns to use in the SELECT statement.
sBeforeQueryColumns - the string to place in the SELECT statement between the SELECT and the first query column.
sWhereClause - the string to place in the SELECT statement after the last WHERE condition from the Filter or MasterReference (Master-Detail Condition).
sAfterWhereClause - the string to place in the SELECT statement after the WHERE clause and before the ORDER BY clause.
pMetaData - the MetaDataColumn array to use.
Returns:
the SELECT statement as String.
Throws:
DataSourceException - if it's not possible to build the select statement in fact of missing elements

getDatabaseSpecificLockStatement

public String getDatabaseSpecificLockStatement(String pWritebackTable,
                                               MetaData pMetaData,
                                               ICondition pPKFilter)
                                        throws DataSourceException
Returns the database specific statement to lock the specified row in the database.

Parameters:
pWritebackTable - the table to use.
pPKFilter - the PK filter with the values to use.
pMetaData - the MetaDataColumn array to use.
Returns:
the database specific statement to lock the specified row in the database.
Throws:
DataSourceException - if some parts are missing for the statement

insertDatabaseSpecific

public Object[] insertDatabaseSpecific(String pWritebackTable,
                                       String pInsertStatement,
                                       MetaData pMetaData,
                                       Object[] pNewDataRow,
                                       String pDummyColumn)
                                throws DataSourceException
Returns the newly inserted row from an Database specific insert statement.
Database specific derivations of DBAcces need to implement it database specific.

Parameters:
pWritebackTable - the table to use for the insert
pInsertStatement - the SQL Statement to use for the insert
pMetaData - the meta data to use.
pNewDataRow - the new row (Object[]) with the values to insert
pDummyColumn - null, if all writeable columns are null, but for a correct INSERT it have to be minimum one column to use in the syntax.
Returns:
the newly inserted row from an Oracle Database.
Throws:
DataSourceException - if an Exception occur during insert to the storage

supportsGetGeneratedKeys

public boolean supportsGetGeneratedKeys()
Returns if this Database specific supports generated keys. Because of Derby!

Returns:
if this Database specific supports generated keys.

insertAnsiSQL

public Object[] insertAnsiSQL(String pWritebackTable,
                              String pInsertStatement,
                              MetaData pMetaData,
                              Object[] pNewDataRow,
                              String pDummyColumn)
                       throws DataSourceException
Returns the newly inserted row from a Ansi SQL Database.
It uses getGeneratedKeys to get the primary key values back from the database. Its recommend that the jdbc driver of the database support that clean.

Parameters:
pWritebackTable - the table to use for the insert
pInsertStatement - the SQL Statement to use for the insert
pMetaData - the meta data to use.
pNewDataRow - the new row (Object[]) with the values to insert
pDummyColumn - true, if all writeable columns are null, but for a correct INSERT it have to be minimum one column to use in the syntax.
Returns:
the newly inserted row from a Ansi SQL Database.
Throws:
DataSourceException - if an Exception occur during insert to the storage

getColumnMetaData

public ColumnMetaData[] getColumnMetaData(String pFromClause,
                                          String[] pQueryColumns,
                                          String pBeforeQueryColumns,
                                          String pWhereClause,
                                          String pAfterWhereClause,
                                          String pWritebackTable,
                                          String[] pWritebackColumns,
                                          String[] pMetaDataContext)
                                   throws DataSourceException
Returns the meta data for the specified query, and initials all columns.

Parameters:
pBeforeQueryColumns - the before query columns
pQueryColumns - the query columns
pFromClause - the from clause with query tables and join definitions
pWhereClause - the last where condition in query
pAfterWhereClause - the after where clause in query
pWritebackTable - the write back table to use for the isWriteable() state (Optional)
pWritebackColumns - the write back columns to use for the isWriteable() state (Optional)
pMetaDataContext - if an String[] with length == 2 is used, the methods returns the MetaData Context back. That's in [0] the Catalog and in [1] the Schema of the pMetaDataQuery, if possible.
Returns:
the meta data for the specified query, and initials all columns.
Throws:
DataSourceException - if an Exception occur during getting the meta data or if the storage isn't opened or if one columns SQL type isn't supported

getWHEREClause

public String getWHEREClause(ICondition pFilter,
                             MetaData pMetaData,
                             boolean pUsePrefix)
Returns the WHERE clause for a UPDATE, DELETE or SELECT statement specified with a Filter.

Parameters:
pFilter - the Filter to use
pMetaData - the MetaData to use
pUsePrefix - true to use the prefixed column (real column name) and false to ignore prefixes (the simple name of the column)
Returns:
the WHERE clause for a UPDATE, DELETE or SELECT statement specified with a Filter.

setFilterParameter

protected void setFilterParameter(int iStartParameterIndex,
                                  PreparedStatement pStatement,
                                  ICondition pFilter)
                           throws DataSourceException
Sets all Filter parameter values into the PreparedStatement.

Parameters:
iStartParameterIndex - the start index for the parameters to set.
pStatement - the PreparedStatement to initialize
pFilter - the Filter to get the values
Throws:
DataSourceException - if the values can't set into the PreparedStatement

setColumnsToStore

protected int setColumnsToStore(PreparedStatement pInsert,
                                ColumnMetaData[] pColumnMetaData,
                                int[] iaWriteables,
                                Object[] pNew,
                                Object[] pOld)
                         throws DataSourceException
Sets the values of all changed columns to store from the value Object[]s into the PreparedStatement and returns the last used parameter index.

Parameters:
pInsert - the PreparedStatement to initialize
pColumnMetaData - the column meta data to use.
iaWriteables - the writable columns as int index array
pNew - the new values Object[]
pOld - the old values Object[]
Returns:
the last used parameter index of the PreparedStatement.
Throws:
DataSourceException - if the values can't set into the PreparedStatement


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.