SolarMetric Kodo JDO 2.4.3 generated on March 27 2003

com.solarmetric.kodo.impl.jdbc
Class SQLExecutionManagerImpl

java.lang.Object
  |
  +--com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl
All Implemented Interfaces:
SQLExecutionManager

public final class SQLExecutionManagerImpl
extends Object
implements SQLExecutionManager

Implementation of SQLExecutionManager that supports PreparedStatements and Statements, and has support for batching together similiar statements.

This class maintains an internal list of SQLBuffers to execute, so that similiar consecutive ones can be batched together for efficiency. Any invocations of executeNow() or executeQuery() will immediately flush the list, since otherwise it would would not be possible to maintain SQL execution order.

Implementation Note: This class does not do any caching of statements itself. Great performance benefits will be yielded from using a DataSource implementation that does caching of PreparedStatements.

Since:
2.4
See Also:
SQLExecutionManager, SQLBuffer

Constructor Summary
SQLExecutionManagerImpl()
           
 
Method Summary
 boolean addSQLExecutionListener(SQLExecutionListener listener)
          Adds a listerer to be notified whenever a SQL event occurs.
 void close()
          Close the underlying Connection to the DataStore.
 void close(ResultSet rs)
          Indicate to the manager that this ResultSet is no longer needed.
 void commit()
          Flush any remaining queued statements and commit to the data store.
 void execute(NonSelectingSQL statement)
          Execute the given SQLBuffer on the Connection, either in a batched or non-batched Statement or PreparedStatement.
 void execute(NonSelectingSQL statement, SQLExecutionCallback callback)
          Execute the given SQLBuffer on the Connection, either in a batched or non-batched Statement or PreparedStatement.
 void execute(SQLBuffer buffer)
          Execute the given SQLBuffer on the Connection, either in a batched or non-batched Statement or PreparedStatement.
 void execute(SQLBuffer buffer, SQLExecutionCallback callback)
           
 int executeNow(NonSelectingSQL statement)
          Execute the given NonSelectingSQL immediately, returning the number of updates made.
 int executeNow(SQLBuffer buffer)
          Execute the given SQLBuffer update the specified Connection, either in a in a non-batched Statement or PreparedStatement.
 int[] executePreparedStatement(SQLBuffer[] buffer)
           Execute the array of SQLBuffer statements as PreparedStatements and return an array of the update counts.
 ResultSet executeQuery(Select select)
          Execute the given Select statement on the specified Connection, either in a batched or non-batched Statement or PreparedStatement.
 ResultSet executeQuery(Select select, int type, int concur)
          Execute the given Select statement on the specified Connection, either in a batched or non-batched Statement or PreparedStatement.
 ResultSet executeQuery(SQLBuffer buffer)
          Execute the given SQLBuffer on the specified Connection, either in a batched or non-batched Statement or PreparedStatement.
 ResultSet executeQuery(SQLBuffer buffer, int type, int concur)
          Execute the given SQLBuffer on the specified Connection, either in a batched or non-batched Statement or PreparedStatement.
 int[] flush()
          Flush any pending statements in the queue and retun an array of the number of update counts.
 Collection getCallbackExceptions()
          Return all user exceptions thrown by callbacks since the end of the last transaction.
 JDBCConfiguration getConfiguration()
          Returns the JDBCConfiguration set in this object upon creation.
 Connection getConnection()
          Returns the Connection that is being used for this manager.
 Connection getConnectionFromFactory()
          Obtain a Connection from the connection factory, after validating it against the DBDictionary.isClosed(java.sql.Connection) method.
 Connector getConnector()
          Return the Connector in use by the SQLExecutionManager.
 DBDictionary getDictionary()
          Returns the DBDictionary to use when creating SQL statements.
 boolean removeSQLExecutionListener(SQLExecutionListener listener)
          Removes a listerer to be notified whenever a SQL event occurs.
 void rollback()
          Rolls back the underlying connection.
 void setConfiguration(JDBCConfiguration config)
          Set the Configuration for this object.
 void setConnector(Connector connector)
          Set the Connector to be used for this manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLExecutionManagerImpl

public SQLExecutionManagerImpl()
Method Detail

setConfiguration

public void setConfiguration(JDBCConfiguration config)
Description copied from interface: SQLExecutionManager
Set the Configuration for this object.
Specified by:
setConfiguration in interface SQLExecutionManager

getConfiguration

public JDBCConfiguration getConfiguration()
Description copied from interface: SQLExecutionManager
Returns the JDBCConfiguration set in this object upon creation. It may never be null.
Specified by:
getConfiguration in interface SQLExecutionManager

setConnector

public void setConnector(Connector connector)
Description copied from interface: SQLExecutionManager
Set the Connector to be used for this manager.
Specified by:
setConnector in interface SQLExecutionManager

getConnector

public Connector getConnector()
Description copied from interface: SQLExecutionManager
Return the Connector in use by the SQLExecutionManager.
Specified by:
getConnector in interface SQLExecutionManager

getConnection

public Connection getConnection()
                         throws SQLException
Description copied from interface: SQLExecutionManager
Returns the Connection that is being used for this manager. The life cycle of this connection will be managed by the SQLExecutionManager.
Specified by:
getConnection in interface SQLExecutionManager

getConnectionFromFactory

public Connection getConnectionFromFactory()
                                    throws SQLException
Obtain a Connection from the connection factory, after validating it against the DBDictionary.isClosed(java.sql.Connection) method.
Returns:
a newly obtained Connection

getDictionary

public DBDictionary getDictionary()
Description copied from interface: SQLExecutionManager
Returns the DBDictionary to use when creating SQL statements.
Specified by:
getDictionary in interface SQLExecutionManager

execute

public void execute(NonSelectingSQL statement)
             throws SQLExceptionWrapper
Description copied from interface: SQLExecutionManager
Execute the given SQLBuffer on the Connection, either in a batched or non-batched Statement or PreparedStatement. After calling a sequence of multiple execute() methods, flush() should be invoked in order to ensure that statements are flushed to the data store. For immediate execution, call the executeNow method.
Specified by:
execute in interface SQLExecutionManager
Following copied from interface: com.solarmetric.kodo.impl.jdbc.SQLExecutionManager
See Also:
SQLExecutionManager.executeNow(com.solarmetric.kodo.impl.jdbc.sql.NonSelectingSQL)

execute

public void execute(NonSelectingSQL statement,
                    SQLExecutionCallback callback)
             throws SQLExceptionWrapper
Description copied from interface: SQLExecutionManager
Execute the given SQLBuffer on the Connection, either in a batched or non-batched Statement or PreparedStatement. After calling a sequence of multiple execute() methods, flush() should be invoked in order to ensure that statements are flushed to the data store. For immediate execution, call the executeNow method.
Specified by:
execute in interface SQLExecutionManager
Following copied from interface: com.solarmetric.kodo.impl.jdbc.SQLExecutionManager
Parameters:
statement - the Statement to execute
callback - the callback to invoke after the update occurs
See Also:
SQLExecutionManager.executeNow(com.solarmetric.kodo.impl.jdbc.sql.NonSelectingSQL)

execute

public void execute(SQLBuffer buffer)
             throws SQLExceptionWrapper
Description copied from interface: SQLExecutionManager
Execute the given SQLBuffer on the Connection, either in a batched or non-batched Statement or PreparedStatement. After calling a sequence of multiple execute() methods, flush() should be invoked in order to ensure that statements are flushed to the data store. For immediate execution, call the executeNow method.
Specified by:
execute in interface SQLExecutionManager
Following copied from interface: com.solarmetric.kodo.impl.jdbc.SQLExecutionManager
See Also:
#executeNow(com.solarmetric.kodo.impl.jdbc.SQLBuffer)

execute

public void execute(SQLBuffer buffer,
                    SQLExecutionCallback callback)
             throws SQLExceptionWrapper

flush

public int[] flush()
            throws SQLExceptionWrapper
Description copied from interface: SQLExecutionManager
Flush any pending statements in the queue and retun an array of the number of update counts.
Specified by:
flush in interface SQLExecutionManager

executeNow

public int executeNow(NonSelectingSQL statement)
               throws SQLExceptionWrapper
Description copied from interface: SQLExecutionManager
Execute the given NonSelectingSQL immediately, returning the number of updates made.
Specified by:
executeNow in interface SQLExecutionManager
Following copied from interface: com.solarmetric.kodo.impl.jdbc.SQLExecutionManager
See Also:
SQLExecutionManager.executeNow(com.solarmetric.kodo.impl.jdbc.sql.NonSelectingSQL)

executeNow

public int executeNow(SQLBuffer buffer)
               throws SQLExceptionWrapper
Description copied from interface: SQLExecutionManager
Execute the given SQLBuffer update the specified Connection, either in a in a non-batched Statement or PreparedStatement.
Specified by:
executeNow in interface SQLExecutionManager

executeQuery

public ResultSet executeQuery(Select select)
                       throws SQLExceptionWrapper
Description copied from interface: SQLExecutionManager
Execute the given Select statement on the specified Connection, either in a batched or non-batched Statement or PreparedStatement.
Specified by:
executeQuery in interface SQLExecutionManager

executeQuery

public ResultSet executeQuery(Select select,
                              int type,
                              int concur)
                       throws SQLExceptionWrapper
Description copied from interface: SQLExecutionManager
Execute the given Select statement on the specified Connection, either in a batched or non-batched Statement or PreparedStatement.
Specified by:
executeQuery in interface SQLExecutionManager
Following copied from interface: com.solarmetric.kodo.impl.jdbc.SQLExecutionManager
Parameters:
type - the type of ResultSet to return
concur - the concurrency of the ResultSet

executeQuery

public ResultSet executeQuery(SQLBuffer buffer)
                       throws SQLExceptionWrapper
Description copied from interface: SQLExecutionManager
Execute the given SQLBuffer on the specified Connection, either in a batched or non-batched Statement or PreparedStatement.
Specified by:
executeQuery in interface SQLExecutionManager

executeQuery

public ResultSet executeQuery(SQLBuffer buffer,
                              int type,
                              int concur)
                       throws SQLExceptionWrapper
Description copied from interface: SQLExecutionManager
Execute the given SQLBuffer on the specified Connection, either in a batched or non-batched Statement or PreparedStatement.
Specified by:
executeQuery in interface SQLExecutionManager
Following copied from interface: com.solarmetric.kodo.impl.jdbc.SQLExecutionManager
Parameters:
type - the type of ResultSet to return
concur - the concurrency of the ResultSet

executePreparedStatement

public int[] executePreparedStatement(SQLBuffer[] buffer)
                               throws SQLException

Execute the array of SQLBuffer statements as PreparedStatements and return an array of the update counts.

This implementation decides to batch together the statements or not depending on the setting of JDBCConfiguration.getUseBatchedStatements()


getCallbackExceptions

public Collection getCallbackExceptions()
Description copied from interface: SQLExecutionManager
Return all user exceptions thrown by callbacks since the end of the last transaction.
Specified by:
getCallbackExceptions in interface SQLExecutionManager

commit

public void commit()
            throws SQLException
Description copied from interface: SQLExecutionManager
Flush any remaining queued statements and commit to the data store.
Specified by:
commit in interface SQLExecutionManager

rollback

public void rollback()
              throws SQLException
Description copied from interface: SQLExecutionManager
Rolls back the underlying connection.
Specified by:
rollback in interface SQLExecutionManager

close

public void close()
           throws SQLException
Description copied from interface: SQLExecutionManager
Close the underlying Connection to the DataStore.
Specified by:
close in interface SQLExecutionManager

close

public void close(ResultSet rs)
           throws SQLException
Description copied from interface: SQLExecutionManager
Indicate to the manager that this ResultSet is no longer needed. The Statement that was used to create the ResultSet should no longer be used, as the implementation may choose to close it or return it to a pool for later reuse.
Specified by:
close in interface SQLExecutionManager

addSQLExecutionListener

public boolean addSQLExecutionListener(SQLExecutionListener listener)
Adds a listerer to be notified whenever a SQL event occurs.
Specified by:
addSQLExecutionListener in interface SQLExecutionManager

removeSQLExecutionListener

public boolean removeSQLExecutionListener(SQLExecutionListener listener)
Removes a listerer to be notified whenever a SQL event occurs.
Specified by:
removeSQLExecutionListener in interface SQLExecutionManager

SolarMetric Kodo JDO 2.4.3 generated on March 27 2003

Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.