org.firebirdsql.pool
Class PooledPreparedStatementHandler
java.lang.Object
|
+--org.firebirdsql.pool.PooledPreparedStatementHandler
- All Implemented Interfaces:
- java.lang.reflect.InvocationHandler
- public class PooledPreparedStatementHandler
- extends java.lang.Object
- implements java.lang.reflect.InvocationHandler
Wrapper for prepared statements. This invocation handler notifies statement
manager about closing prepared statement.
- Author:
- Roman Rokytskyy
Method Summary |
protected void |
checkCorrectness(java.lang.reflect.Method method)
Check if method call is correct. |
static java.lang.reflect.Method |
findMethod(java.lang.Class clazz,
java.lang.String name,
java.lang.Class[] params)
|
protected void |
handleForceClose()
|
protected boolean |
handleIsCached()
|
protected void |
handleStatementClose(java.lang.String statement,
java.lang.Object proxy)
Handle Statement.close() call. |
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Invoke method on a specified proxy. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
findMethod
public static java.lang.reflect.Method findMethod(java.lang.Class clazz,
java.lang.String name,
java.lang.Class[] params)
handleStatementClose
protected void handleStatementClose(java.lang.String statement,
java.lang.Object proxy)
throws java.sql.SQLException
- Handle
Statement.close()
call.
- Parameters:
statement
- SQL statement corresponding to the wrapped prepared
statement.proxy
- dynamic proxy wrapping prepared statement.- Throws:
java.sql.SQLException
- if something went wrong.
handleForceClose
protected void handleForceClose()
throws java.sql.SQLException
handleIsCached
protected boolean handleIsCached()
throws java.sql.SQLException
invoke
public java.lang.Object invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
- Invoke method on a specified proxy. Here we check if
method
is a method Statement.close()
. If yes, we notify owner
that this prepared statement was closed.
- Specified by:
invoke
in interface java.lang.reflect.InvocationHandler
- Parameters:
proxy
- proxy on which method is invoked.method
- instance of Method
describing method being invoked.args
- array with arguments.- Returns:
- result of method invokation.
- Throws:
java.lang.Throwable
- if invoked method threw an exception.
checkCorrectness
protected void checkCorrectness(java.lang.reflect.Method method)
throws java.sql.SQLException
- Check if method call is correct. If method was declared in
PreparedStatement
class and there is no connection proxy
associated with this statement (i.e. statement in in pool), exception is
thrown (this situation usually happens if somebody tries to call method
on prepared statement after it has been closed).
- Parameters:
method
- method to check.- Throws:
java.sql.SQLException
- if statement has incorrect statement.
Copyright © 2001 David Jencks and other authors. All rights reserved.