|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jcreme.sql.WrappedConnection
This class enables to wrap an actual connection to provide a few extra services: access the active statements attached to the connection, handling of some exceptions (rollback, loss of connection). The statements provided by this class are wrapped around the actual statement.
Field Summary | |
protected static java.lang.String |
LOSS_OF_CONNECTION_METHOD_NAME
Name of the method to use in case of loss of connection. |
protected static java.lang.Class[] |
LOSS_OF_CONNECTION_PARAMETERS
Types of the parameters to the loss of connection method. |
protected static java.lang.String |
ROLLBACK_METHOD_NAME
Name of the method to use in case of rollback. |
protected static java.lang.Class[] |
ROLLBACK_PARAMETERS
Types of the parameters to the rollback method. |
Fields inherited from interface java.sql.Connection |
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE |
Constructor Summary | |
protected |
WrappedConnection(java.sql.Connection connection)
Create the wrapping around a database Connection. |
Method Summary | |
void |
clearWarnings()
|
void |
close()
|
void |
commit()
|
protected void |
connectionExternallyClosed()
This method enables to actually close the connection when it is lost. |
java.sql.Statement |
createStatement()
|
java.sql.Statement |
createStatement(int i,
int j)
|
java.sql.Statement |
createStatement(int i,
int j,
int k)
|
java.sql.Statement[] |
getActiveStatements()
This method gives access to the statements that are currently registered in the Connection. |
boolean |
getAutoCommit()
|
java.lang.String |
getCatalog()
|
SQLExceptionHandler |
getExceptionHandler()
Gives access to the Exception handler that is used by this Connection. |
int |
getHoldability()
|
static WrappedConnection |
getInstance(java.sql.Connection connection)
This method enables to build or retrieve the WrappedConnection created from a given connection. |
CremeAction |
getLossOfConnectionAction()
Gives access to the action that enables to close this Connection in case of loss of connection. |
static java.lang.reflect.Method |
getLossOfConnectionMethod()
Gives access to the method that is used to handle loss of connection in this class. |
java.sql.DatabaseMetaData |
getMetaData()
|
ConnectionPool |
getParentPool()
Gives access to the eventual ConnectionPool to which this connection is attached. |
CremeAction |
getRollBackAction()
Gives access to the action that enables to rollback this Connection. |
static java.lang.reflect.Method |
getRollbackMethod()
Gives access to the method that is used to rollback in this class. |
int |
getTransactionIsolation()
|
java.util.Map |
getTypeMap()
|
java.sql.SQLWarning |
getWarnings()
|
boolean |
isClosed()
|
boolean |
isReadOnly()
|
protected int |
manageException(java.sql.SQLException e)
This method enables the Connection to handle the exceptions. |
protected int |
manageException(java.sql.SQLException e,
CremeAction redo)
This method enables the Connection to handle the exceptions. |
java.lang.String |
nativeSQL(java.lang.String sql)
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql)
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int i,
int j)
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int i,
int j,
int k)
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int i)
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int[] i)
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int i,
int j)
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int i,
int j,
int k)
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.String[] s)
|
protected void |
registerActiveStatement(java.sql.Statement statement)
This method is called when a Statement is created from this Connection. |
void |
releaseSavepoint(java.sql.Savepoint savepoint)
|
void |
rollback()
|
void |
rollback(java.sql.Savepoint savepoint)
|
void |
setAutoCommit(boolean flag)
|
void |
setCatalog(java.lang.String s)
|
void |
setExceptionHandler(SQLExceptionHandler handler)
Sets the Exception Handler for this connection. |
void |
setHoldability(int i)
|
void |
setParentPool(ConnectionPool pool)
This method enabes to attach this WrappedConnection to a ConnectionPool. |
void |
setReadOnly(boolean readOnly)
|
java.sql.Savepoint |
setSavepoint()
|
java.sql.Savepoint |
setSavepoint(java.lang.String name)
|
void |
setTransactionIsolation(int i)
|
void |
setTypeMap(java.util.Map map)
|
protected void |
unregisterActiveStatement(java.sql.Statement statement)
This method is called when a Statement created in this Connection is closed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final java.lang.String ROLLBACK_METHOD_NAME
protected static final java.lang.Class[] ROLLBACK_PARAMETERS
protected static final java.lang.String LOSS_OF_CONNECTION_METHOD_NAME
protected static final java.lang.Class[] LOSS_OF_CONNECTION_PARAMETERS
Constructor Detail |
protected WrappedConnection(java.sql.Connection connection) throws java.sql.SQLException
connection
- the connection to wrap.
java.sql.SQLException
- if connection is null.Method Detail |
public static WrappedConnection getInstance(java.sql.Connection connection)
connection
- the connection for which we want a wrapper.
public static java.lang.reflect.Method getRollbackMethod()
public static java.lang.reflect.Method getLossOfConnectionMethod()
public void setParentPool(ConnectionPool pool)
pool
- the ConnectionPool to attach.public ConnectionPool getParentPool()
public void setExceptionHandler(SQLExceptionHandler handler)
handler
- the handler that will be used for all the SQLExceptions.public SQLExceptionHandler getExceptionHandler()
public CremeAction getRollBackAction()
public CremeAction getLossOfConnectionAction()
protected void connectionExternallyClosed() throws java.sql.SQLException
java.sql.SQLException
- if an error occurs while closing the connection.protected int manageException(java.sql.SQLException e)
e
- the SQLException to handle.
protected int manageException(java.sql.SQLException e, CremeAction redo)
e
- the SQLException to handle.redo
- the action that has provoked the exception. It will be called
again if possible.
public void setCatalog(java.lang.String s) throws java.sql.SQLException
setCatalog
in interface java.sql.Connection
java.sql.SQLException
Connection.setCatalog(java.lang.String)
public void close() throws java.sql.SQLException
close
in interface java.sql.Connection
java.sql.SQLException
Connection.close()
public void clearWarnings() throws java.sql.SQLException
clearWarnings
in interface java.sql.Connection
java.sql.SQLException
Connection.clearWarnings()
public void rollback() throws java.sql.SQLException
rollback
in interface java.sql.Connection
java.sql.SQLException
Connection.rollback()
public java.util.Map getTypeMap() throws java.sql.SQLException
getTypeMap
in interface java.sql.Connection
java.sql.SQLException
Connection.getTypeMap()
public int getTransactionIsolation() throws java.sql.SQLException
getTransactionIsolation
in interface java.sql.Connection
java.sql.SQLException
Connection.getTransactionIsolation()
public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
Connection.prepareStatement(java.lang.String)
public void setTransactionIsolation(int i) throws java.sql.SQLException
setTransactionIsolation
in interface java.sql.Connection
java.sql.SQLException
Connection.setTransactionIsolation(int)
public boolean isClosed() throws java.sql.SQLException
isClosed
in interface java.sql.Connection
java.sql.SQLException
Connection.isClosed()
public java.sql.Statement createStatement() throws java.sql.SQLException
createStatement
in interface java.sql.Connection
java.sql.SQLException
Connection.createStatement()
public java.sql.Statement createStatement(int i, int j) throws java.sql.SQLException
createStatement
in interface java.sql.Connection
java.sql.SQLException
Connection.createStatement(int, int)
public void setAutoCommit(boolean flag) throws java.sql.SQLException
setAutoCommit
in interface java.sql.Connection
java.sql.SQLException
Connection.setAutoCommit(boolean)
public java.sql.CallableStatement prepareCall(java.lang.String sql, int i, int j) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
java.sql.SQLException
Connection.prepareCall(java.lang.String, int, int)
public void commit() throws java.sql.SQLException
commit
in interface java.sql.Connection
java.sql.SQLException
Connection.commit()
public java.lang.String getCatalog() throws java.sql.SQLException
getCatalog
in interface java.sql.Connection
java.sql.SQLException
Connection.getCatalog()
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int i, int j) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
Connection.prepareStatement(java.lang.String, int, int)
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException
getMetaData
in interface java.sql.Connection
java.sql.SQLException
Connection.getMetaData()
public boolean getAutoCommit() throws java.sql.SQLException
getAutoCommit
in interface java.sql.Connection
java.sql.SQLException
Connection.getAutoCommit()
public java.lang.String nativeSQL(java.lang.String sql) throws java.sql.SQLException
nativeSQL
in interface java.sql.Connection
java.sql.SQLException
Connection.nativeSQL(java.lang.String)
public java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
java.sql.SQLException
Connection.prepareCall(java.lang.String)
public void setTypeMap(java.util.Map map) throws java.sql.SQLException
setTypeMap
in interface java.sql.Connection
java.sql.SQLException
Connection.setTypeMap(java.util.Map)
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException
getWarnings
in interface java.sql.Connection
java.sql.SQLException
Connection.getWarnings()
protected void registerActiveStatement(java.sql.Statement statement)
statement
- the statement to attach to this Connection.protected void unregisterActiveStatement(java.sql.Statement statement)
statement
- the statement to unregister.public java.sql.Statement[] getActiveStatements()
public void setHoldability(int i) throws java.sql.SQLException
setHoldability
in interface java.sql.Connection
java.sql.SQLException
Connection.setHoldability(int)
public int getHoldability() throws java.sql.SQLException
getHoldability
in interface java.sql.Connection
java.sql.SQLException
Connection.getHoldability()
public void rollback(java.sql.Savepoint savepoint) throws java.sql.SQLException
rollback
in interface java.sql.Connection
java.sql.SQLException
Connection.rollback(java.sql.Savepoint)
public java.sql.Statement createStatement(int i, int j, int k) throws java.sql.SQLException
createStatement
in interface java.sql.Connection
java.sql.SQLException
Connection.createStatement(int, int, int)
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int i, int j, int k) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
Connection.prepareStatement(java.lang.String,int,int,int)
public java.sql.CallableStatement prepareCall(java.lang.String sql, int i, int j, int k) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
java.sql.SQLException
Connection.prepareCall(java.lang.String, int, int, int)
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int i) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
Connection.prepareStatement(java.lang.String, int)
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] i) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
Connection.prepareStatement(java.lang.String, int[])
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] s) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
Connection.prepareStatement(java.lang.String, java.lang.String[])
public boolean isReadOnly() throws java.sql.SQLException
isReadOnly
in interface java.sql.Connection
java.sql.SQLException
Connection.isReadOnly()
public void releaseSavepoint(java.sql.Savepoint savepoint) throws java.sql.SQLException
releaseSavepoint
in interface java.sql.Connection
java.sql.SQLException
Connection.releaseSavepoint(java.sql.Savepoint)
public void setReadOnly(boolean readOnly) throws java.sql.SQLException
setReadOnly
in interface java.sql.Connection
java.sql.SQLException
Connection.setReadOnly(boolean)
public java.sql.Savepoint setSavepoint() throws java.sql.SQLException
setSavepoint
in interface java.sql.Connection
java.sql.SQLException
Connection.setSavepoint()
public java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLException
setSavepoint
in interface java.sql.Connection
java.sql.SQLException
Connection.setSavepoint(java.lang.String)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |