-
- All Superinterfaces:
EventListener
public interface StatementEventListener extends EventListener
An object that registers to be notified of events that occur on PreparedStatements that are in the Statement pool.The JDBC 3.0 specification added the maxStatements
ConnectionPooledDataSourceproperty to provide a standard mechanism for enabling the pooling ofPreparedStatementsand to specify the size of the statement pool. However, there was no way for a driver to notify an external statement pool when aPreparedStatementbecomes invalid. For some databases, a statement becomes invalid if a DDL operation is performed that affects the table. For example an application may create a temporary table to do some work on the table and then destroy it. It may later recreate the same table when it is needed again. Some databases will invalidate any prepared statements that reference the temporary table when the table is dropped.Similar to the methods defined in the
ConnectionEventListenerinterface, the driver will call theStatementEventListener.statementErrorOccurredmethod prior to throwing any exceptions when it detects a statement is invalid. The driver will also call theStatementEventListener.statementClosedmethod when aPreparedStatementis closed.Methods which allow a component to register a StatementEventListener with a
PooledConnectionhave been added to thePooledConnectioninterface.- Since:
- 1.6
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidstatementClosed(StatementEvent event)The driver calls this method on allStatementEventListeners registered on the connection when it detects that aPreparedStatementis closed.voidstatementErrorOccurred(StatementEvent event)The driver calls this method on allStatementEventListeners registered on the connection when it detects that aPreparedStatementis invalid.
-
-
-
Method Detail
-
statementClosed
void statementClosed(StatementEvent event)
The driver calls this method on allStatementEventListeners registered on the connection when it detects that aPreparedStatementis closed.- Parameters:
event- an event object describing the source of the event and that thePreparedStatementwas closed.- Since:
- 1.6
-
statementErrorOccurred
void statementErrorOccurred(StatementEvent event)
The driver calls this method on allStatementEventListeners registered on the connection when it detects that aPreparedStatementis invalid. The driver calls this method just before it throws theSQLException, contained in the given event, to the application.- Parameters:
event- an event object describing the source of the event, the statement that is invalid and the exception the driver is about to throw. The source of the event is thePooledConnectionwhich the invalidPreparedStatementis associated with.- Since:
- 1.6
-
-