| java.lang.Object org.jaffa.persistence.engines.jdbcengine.datasource.DataSource
DataSource | public class DataSource (Code) | | Encapsulates the connection to a data storage mechanism
|
Constructor Summary | |
| DataSource(Connection connection, Integer hitlistSize, String engineType, Boolean usePreparedStatement, Map statementCache) Creates a new data source.
The cache for PreparedStatement and CallableStatement objects is maintained outside of this class, since we are going to pool only the connections & not the datasource itself.
If the cache is not supplied initially, then the cache will be maintained for the lifecycle of a datasource only, as opposed to the pooled-connection.
Parameters: connection - The connection to the database. Parameters: hitlistSize - The size of the hitlist. Parameters: engineType - The engine type as defined in init.xml Parameters: usePreparedStatement - Decides if PreparedStatements are to be used for Inserts, Updates, Deletes, Locks. |
DataSource | DataSource(Connection connection, Integer hitlistSize, String engineType, Boolean usePreparedStatement, Map statementCache)(Code) | | Creates a new data source.
The cache for PreparedStatement and CallableStatement objects is maintained outside of this class, since we are going to pool only the connections & not the datasource itself.
If the cache is not supplied initially, then the cache will be maintained for the lifecycle of a datasource only, as opposed to the pooled-connection.
Parameters: connection - The connection to the database. Parameters: hitlistSize - The size of the hitlist. Parameters: engineType - The engine type as defined in init.xml Parameters: usePreparedStatement - Decides if PreparedStatements are to be used for Inserts, Updates, Deletes, Locks. This property should be set to 'false' if the primary key of a table has 'CHAR' field(s). Parameters: statementCache - the cache used by the connection for all the PreparedStatement and CallableStatement objects. |
closeStatement | public void closeStatement(Statement statement) throws SQLException(Code) | | Closes the statement and removes it from the internal collection.
Parameters: statement - the Statement object to be closed. throws: SQLException - if any database error occurs. |
commit | public void commit() throws SQLException(Code) | | Commits all changes executed against the persistent store.
throws: SQLException - if any database error occurs. |
executeQuery | public Collection executeQuery(String sql, ClassMetaData classMetaData, Criteria criteria, int queryTimeout) throws SQLException, PostLoadFailedException, DataSourceCursorRuntimeException, IOException(Code) | | Executes a query against the underlying data source. Returns a Collection of persistent objects.
The Statement object that is internally used for executing the query, will be automatically closed, once the recordset has been completely traversed.
Parameters: sql - The query to execute. Parameters: classMetaData - The ClassMetaData defintion to be used for molding the ResultSet into Persistent objects. Parameters: criteria - The Criteria used for the query. This will provide the values to set the various flags on the Persistent object. Parameters: queryTimeout - This will be used for setting the timeout value on the Statement object; zero means there is no limit. throws: SQLException - if any database error occurs. throws: PostLoadFailedException - if any error is thrown in the PostLoad trigger of the persistent object. throws: DataSourceCursorRuntimeException - if any error occurs while molding the row into the Persistent object. throws: IOException - if any error occurs in reading the data from the database. a Collection of persistent objects. |
executeUpdate | public void executeUpdate(String sql) throws SQLException(Code) | | Executes the sql, which should be an update/insert/delete statement.
The Statement object that is internally used for executing the update, will be immediately closed.
Parameters: sql - the sql to execute. throws: SQLException - if any database error occurs. |
executeUpdate | public void executeUpdate(PreparedStatement stmt) throws SQLException(Code) | | Execute the input PreparedStatement.
The calling program is expected to close the ResultSet(s), if any, that might be returned by executing the update.
Parameters: stmt - the PreparedStatement to execute. throws: SQLException - if any database error occurs. |
getCallableStatement | public CallableStatement getCallableStatement(String sql) throws SQLException(Code) | | Returns the CallableStatement object for the input sql. The CallableStatement object will be cached for the connection.
Parameters: sql - the sql statement. throws: SQLException - if any database error occurs. the CallableStatement object. |
getConnection | Connection getConnection()(Code) | | Returns the Connection object, used for creating the DataSource.
a Connection. |
getEngineType | public String getEngineType()(Code) | | Getter for property engineType, as defined in init.xml
Value of property engineType. |
getHitlistSize | public Integer getHitlistSize()(Code) | | Getter for property hitlistSize.
Value of property hitlistSize. |
getPreparedStatement | public PreparedStatement getPreparedStatement(String sql) throws SQLException(Code) | | Returns the PreparedStatement object for the input sql. The PreparedStatement object will be cached for the connection.
Parameters: sql - the sql statement which needs to be precompiled. throws: SQLException - if any database error occurs. the PreparedStatement object. |
getStatement | public Statement getStatement() throws SQLException(Code) | | Returns a Statement object. This object will be added to an internal collection and will be closed when the DataSource is closed.
It is a good idea to invoke the closeStatement() method when done with the statement.
throws: SQLException - if any database error occurs. the Statement object. |
getUsePreparedStatement | public Boolean getUsePreparedStatement()(Code) | | Getter for property usePreparedStatement.
Value of property usePreparedStatement. |
rollback | public void rollback() throws SQLException(Code) | | Rollback the changes executed against the persistent store.
throws: SQLException - if any database error occurs. |
|
|