|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.boylesoftware.cb2.util.sql.ConnectionWrapper
Wrapper around a JDBC's Connection
interface
implementation. You can derive your connection wrapper classes from
this one and override some of its methods, while all the others
will be calling appropriate methods on the wrapped, "real" connection.
This class also provides some "hook" methods called in certain situations. Note that if your redefine interface methods in your subclass and you use hooks you will have to call the base method from your redefined one in order to make the hooks invoked. Alternatively you call them yourself directly from the redefined interface method.
Field Summary | |
protected java.sql.Connection |
con
The wrapped connection. |
Fields inherited from interface java.sql.Connection |
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE |
Constructor Summary | |
ConnectionWrapper()
Creates a new wrapper. |
|
ConnectionWrapper(java.sql.Connection con)
Creates a new wrapper and sets the wrapped connection to the specified one. |
Method Summary | |
void |
clearWarnings()
Interface method wrapper. |
void |
close()
Interface method wrapper. |
void |
commit()
Interface method wrapper. |
java.sql.Statement |
createStatement()
Interface method wrapper. |
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency)
Interface method wrapper. |
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Interface method wrapper. |
protected java.sql.Statement |
createStatementHook(java.sql.Statement stmt,
java.lang.String sql)
This hook method is called from all the methods that create all kinds of database statements, including prepared and callable statements. |
protected void |
finalize()
Called by the garbage collector. |
boolean |
getAutoCommit()
Interface method wrapper. |
java.lang.String |
getCatalog()
Interface method wrapper. |
int |
getHoldability()
Interface method wrapper. |
java.sql.DatabaseMetaData |
getMetaData()
Interface method wrapper. |
int |
getTransactionIsolation()
Interface method wrapper. |
java.util.Map |
getTypeMap()
Interface method wrapper. |
java.sql.SQLWarning |
getWarnings()
Interface method wrapper. |
java.sql.Connection |
getWrappedConnection()
Returns the wrapped connection. |
boolean |
isClosed()
Interface method wrapper. |
boolean |
isReadOnly()
Interface method wrapper. |
java.lang.String |
nativeSQL(java.lang.String sql)
Interface method wrapper. |
protected void |
postCallHook()
This hook is invoked after every interface method call. |
java.sql.CallableStatement |
prepareCall(java.lang.String sql)
Interface method wrapper. |
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
Interface method wrapper. |
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Interface method wrapper. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
Interface method wrapper. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int autoGeneratedKeys)
Interface method wrapper. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int[] columnIndexes)
Interface method wrapper. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
Interface method wrapper. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Interface method wrapper. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.String[] columnNames)
Interface method wrapper. |
void |
releaseSavepoint(java.sql.Savepoint savepoint)
Interface method wrapper. |
void |
rollback()
Interface method wrapper. |
void |
rollback(java.sql.Savepoint savepoint)
Interface method wrapper. |
void |
setAutoCommit(boolean autoCommit)
Interface method wrapper. |
void |
setCatalog(java.lang.String catalog)
Interface method wrapper. |
void |
setHoldability(int holdability)
Interface method wrapper. |
void |
setReadOnly(boolean readOnly)
Interface method wrapper. |
java.sql.Savepoint |
setSavepoint()
Interface method wrapper. |
java.sql.Savepoint |
setSavepoint(java.lang.String name)
Interface method wrapper. |
void |
setTransactionIsolation(int level)
Interface method wrapper. |
void |
setTypeMap(java.util.Map map)
Interface method wrapper. |
void |
setWrappedConnection(java.sql.Connection con)
Sets the wrapped connection. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.sql.Connection con
Constructor Detail |
public ConnectionWrapper()
setWrappedConnection
call before using the
instance.
public ConnectionWrapper(java.sql.Connection con)
con
- the connection to be wrapped.Method Detail |
public void setWrappedConnection(java.sql.Connection con)
con
- connection to wrap.public java.sql.Connection getWrappedConnection()
protected void finalize() throws java.sql.SQLException
java.sql.SQLException
- if the connection could not be closed.public java.sql.Statement createStatement() throws java.sql.SQLException
Also calles createStatementHook
hook.
createStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
Also calles createStatementHook
hook.
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException
Also calles createStatementHook
hook.
prepareCall
in interface java.sql.Connection
java.sql.SQLException
public java.lang.String nativeSQL(java.lang.String sql) throws java.sql.SQLException
nativeSQL
in interface java.sql.Connection
java.sql.SQLException
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException
setAutoCommit
in interface java.sql.Connection
java.sql.SQLException
public boolean getAutoCommit() throws java.sql.SQLException
getAutoCommit
in interface java.sql.Connection
java.sql.SQLException
public void commit() throws java.sql.SQLException
commit
in interface java.sql.Connection
java.sql.SQLException
public void rollback() throws java.sql.SQLException
rollback
in interface java.sql.Connection
java.sql.SQLException
public void close() throws java.sql.SQLException
close
in interface java.sql.Connection
java.sql.SQLException
public boolean isClosed() throws java.sql.SQLException
isClosed
in interface java.sql.Connection
java.sql.SQLException
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException
getMetaData
in interface java.sql.Connection
java.sql.SQLException
public void setReadOnly(boolean readOnly) throws java.sql.SQLException
setReadOnly
in interface java.sql.Connection
java.sql.SQLException
public boolean isReadOnly() throws java.sql.SQLException
isReadOnly
in interface java.sql.Connection
java.sql.SQLException
public void setCatalog(java.lang.String catalog) throws java.sql.SQLException
setCatalog
in interface java.sql.Connection
java.sql.SQLException
public java.lang.String getCatalog() throws java.sql.SQLException
getCatalog
in interface java.sql.Connection
java.sql.SQLException
public void setTransactionIsolation(int level) throws java.sql.SQLException
setTransactionIsolation
in interface java.sql.Connection
java.sql.SQLException
public int getTransactionIsolation() throws java.sql.SQLException
getTransactionIsolation
in interface java.sql.Connection
java.sql.SQLException
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException
getWarnings
in interface java.sql.Connection
java.sql.SQLException
public void clearWarnings() throws java.sql.SQLException
clearWarnings
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
Also calles createStatementHook
hook.
createStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
Also calles createStatementHook
hook.
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
Also calles createStatementHook
hook.
prepareCall
in interface java.sql.Connection
java.sql.SQLException
public java.util.Map getTypeMap() throws java.sql.SQLException
getTypeMap
in interface java.sql.Connection
java.sql.SQLException
public void setTypeMap(java.util.Map map) throws java.sql.SQLException
setTypeMap
in interface java.sql.Connection
java.sql.SQLException
public void setHoldability(int holdability) throws java.sql.SQLException
setHoldability
in interface java.sql.Connection
java.sql.SQLException
public int getHoldability() throws java.sql.SQLException
getHoldability
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Savepoint setSavepoint() throws java.sql.SQLException
setSavepoint
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLException
setSavepoint
in interface java.sql.Connection
java.sql.SQLException
public void rollback(java.sql.Savepoint savepoint) throws java.sql.SQLException
rollback
in interface java.sql.Connection
java.sql.SQLException
public void releaseSavepoint(java.sql.Savepoint savepoint) throws java.sql.SQLException
releaseSavepoint
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
Also calles createStatementHook
hook.
createStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
Also calles createStatementHook
hook.
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
Also calles createStatementHook
hook.
prepareCall
in interface java.sql.Connection
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
Also calles createStatementHook
hook.
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
Also calles createStatementHook
hook.
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
Also calles createStatementHook
hook.
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
protected void postCallHook() throws java.sql.SQLException
java.sql.SQLException
- to indicate an error in the method.protected java.sql.Statement createStatementHook(java.sql.Statement stmt, java.lang.String sql) throws java.sql.SQLException
stmt
parameter back, but you can override this method in a subclass.
stmt
- statement returned by the underlying wrapped connection.sql
- SQL text passed to a prepareStatement or
prepareCall
method, null
if it was
createStatement
call.
- Returns:
- object that should be returned to the caller.
- Throws:
java.sql.SQLException
- if an error happened.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |