Class StatementDecoratorInterceptor.StatementProxy<T extends Statement>
- Type Parameters:
T- The type of Statement being proxied.
- All Implemented Interfaces:
InvocationHandler
- Direct Known Subclasses:
StatementCache.CachedStatement
- Enclosing class:
StatementDecoratorInterceptor
StatementDecoratorInterceptor.RESULTSET_TYPES.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when the close method is invoked on the statement.booleanReturns the actual proxy object.Returns the connection proxy most recently bound throughsetConnection(Object).Constructor<?> Returns the constructor used to create this proxy.Returns the delegated statement.getSql()Returns the SQL text.inthashCode()voidsetActualProxy(Object proxy) Sets the actual proxy object.voidsetConnection(Object proxy) Binds the connection handle thatgetConnection()will report for this statement.voidsetConstructor(Constructor<?> constructor) Sets the constructor for creating proxies.toString()
-
Field Details
-
closed
protected volatile boolean closedIndicates whether this statement has been closed. A statement can be closed from a thread other than the one executing on it - the statement finalizer closes tracked statements from whichever thread closes the connection, and the statement cache forces a close from its own purge - so the flag is written by one thread and read by others, and must be volatile to reach them at all. -
delegate
-
-
Constructor Details
-
StatementProxy
-
-
Method Details
-
getDelegate
-
getSql
-
setConnection
Binds the connection handle thatgetConnection()will report for this statement.createDecoratorbinds the handle of the borrow that creates the statement, andStatementCacheseeds the closing borrow's handle when it parks a statement; the binding is kept as a snapshot and is never refreshed on its own. A handle kept past its borrow is inert by design, so anything reusing a statement proxy across borrows must call this method with the new borrower's handle before the proxy is handed out, asStatementCachedoes on a cache hit.- Parameters:
proxy- the connection proxy
-
getConnection
Returns the connection proxy most recently bound throughsetConnection(Object). While that binding's borrow is current it is a live handle; a statement kept past its borrow answers with the disposed facade it came from. Once the statement is closed the handler refuses the call before it reaches the snapshot, so a stale binding is only visible through diagnostics such astoString().- Returns:
- the connection proxy
-
setActualProxy
Sets the actual proxy object.- Parameters:
proxy- the actual proxy
-
getActualProxy
-
getConstructor
Returns the constructor used to create this proxy.- Returns:
- the constructor
-
setConstructor
Sets the constructor for creating proxies.- Parameters:
constructor- the constructor
-
closeInvoked
Called when the close method is invoked on the statement.The driver's answer is passed on to the caller:
Statement.close()declaresSQLExceptionfor a database error while closing, and this proxy reports every other call as the delegate answered it, so a failed close must not come back as a success. The swallowed failure this replaces told the application that the statement was closed while the driver had left its resources on the session the pooled connection was about to hand to the next borrower, and nothing along the path recorded or retried it.The handle is retired whichever way the driver answered: the application has been told, and a handle whose close failed must not go on answering calls on a statement the driver may have half released. Where no application waits on the close - the cache dropping a statement, see
StatementCache.closeStatement(StatementCache.CachedStatement)- the failure is answered with a log line instead, so that one statement that will not close cannot stop the rest of that purge.- Throws:
SQLException- if the underlying statement could not be closed
-
invoke
-
hashCode
-
equals
-
toString
-