org.jwarp.service.connectionpool
Class ConnectionWrapper

java.lang.Object
  |
  +--org.jwarp.service.connectionpool.ConnectionWrapper
All Implemented Interfaces:
java.sql.Connection

class ConnectionWrapper
extends java.lang.Object
implements java.sql.Connection

This class is a wrapper around a Connection, overriding the close method to just inform the pool that it's available for reuse again, and the isClosed method to return the state of the wrapper instead of the Connection.

Version:
1.0
Author:
Anatole Tresch

Field Summary
(package private)  java.sql.Connection realConn
          The underlying sql connection
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
ConnectionWrapper(java.sql.Connection realConn, ConnectionPool pool, LogWriter log)
          Constructs a new connection wrapper
 
Method Summary
 void clearWarnings()
          Wrapped methods from the connection interface.
 void close()
          Inform the ConnectionPool that the ConnectionWrapper is closed.
 void commit()
          Wrapped methods from the connection interface.
 java.sql.Statement createStatement()
          Wrapped methods from the connection interface.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency)
          Wrapped methods from the connection interface.
 void finalize()
          If the wrapper has not been closed, it is closed now.
 boolean getAutoCommit()
          Wrapped methods from the connection interface.
 java.lang.String getCatalog()
          Wrapped methods from the connection interface.
 java.sql.DatabaseMetaData getMetaData()
          Wrapped methods from the connection interface.
 ConnectionPool getPool()
          Returns the pool of the connection.
 int getTransactionIsolation()
          Wrapped methods from the connection interface.
 java.util.Map getTypeMap()
          Wrapped methods from the connection interface.
static int getUnclosedConnectionsFinalized()
           
 java.sql.SQLWarning getWarnings()
          Wrapped methods from the connection interface.
 boolean isClosed()
          Returns true if the ConnectionWrapper is closed, false otherwise.
 boolean isReadOnly()
          Wrapped methods from the connection interface.
 java.lang.String nativeSQL(java.lang.String sql)
          Wrapped methods from the connection interface.
 java.sql.CallableStatement prepareCall(java.lang.String sql)
          Wrapped methods from the connection interface.
 java.sql.CallableStatement prepareCall(java.lang.String sql, int i1, int i2)
          Wrapped methods from the connection interface.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          Wrapped methods from the connection interface.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int i1, int i2)
          Wrapped methods from the connection interface.
 void rollback()
          Wrapped methods from the connection interface.
 void setAutoCommit(boolean autoCommit)
          Wrapped methods from the connection interface.
 void setCatalog(java.lang.String catalog)
          Wrapped methods from the connection interface.
 void setReadOnly(boolean readOnly)
          Wrapped methods from the connection interface.
 void setTransactionIsolation(int level)
          Wrapped methods from the connection interface.
 void setTypeMap(java.util.Map map)
          Wrapped methods from the connection interface.
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

realConn

java.sql.Connection realConn
The underlying sql connection
Constructor Detail

ConnectionWrapper

public ConnectionWrapper(java.sql.Connection realConn,
                         ConnectionPool pool,
                         LogWriter log)
Constructs a new connection wrapper
Parameters:
realConn - The JDBC connection
pool - The ConnectionPoool that manages the connection.
Method Detail

close

public void close()
           throws java.sql.SQLException
Inform the ConnectionPool that the ConnectionWrapper is closed.
Specified by:
close in interface java.sql.Connection
Throws:
java.sql.SQLException -  

isClosed

public boolean isClosed()
                 throws java.sql.SQLException
Returns true if the ConnectionWrapper is closed, false otherwise.
Specified by:
isClosed in interface java.sql.Connection
Returns:
true if the connection was closed by the client
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface

getPool

public ConnectionPool getPool()
Returns the pool of the connection.
Returns:
the connection pool

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
clearWarnings in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

commit

public void commit()
            throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
commit in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

createStatement

public java.sql.Statement createStatement()
                                   throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency)
                                   throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

getAutoCommit

public boolean getAutoCommit()
                      throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
getAutoCommit in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

getCatalog

public java.lang.String getCatalog()
                            throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
getCatalog in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                      throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
getMetaData in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

getTransactionIsolation

public int getTransactionIsolation()
                            throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
getTransactionIsolation in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
getWarnings in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

isReadOnly

public boolean isReadOnly()
                   throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
isReadOnly in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

nativeSQL

public java.lang.String nativeSQL(java.lang.String sql)
                           throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
nativeSQL in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                       throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

rollback

public void rollback()
              throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
rollback in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
setAutoCommit in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

setCatalog

public void setCatalog(java.lang.String catalog)
                throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
setCatalog in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
setReadOnly in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
setTransactionIsolation in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

setTypeMap

public void setTypeMap(java.util.Map map)
                throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
setTypeMap in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int i1,
                                                   int i2)
                                            throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int i1,
                                              int i2)
                                       throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

getTypeMap

public java.util.Map getTypeMap()
                         throws java.sql.SQLException
Wrapped methods from the connection interface.
Specified by:
getTypeMap in interface java.sql.Connection
Throws:
java.sql.SQLException - must be thrown for implementing the connection interface
See Also:
Connection

finalize

public void finalize()
If the wrapper has not been closed, it is closed now. Should actually not happen.
Overrides:
finalize in class java.lang.Object

getUnclosedConnectionsFinalized

public static int getUnclosedConnectionsFinalized()

©   O R C A   S y s t e m s