Protomatter Software v1.1.8

com.protomatter.jdbc.pool
Class JdbcConnectionPoolConnection

java.lang.Object
  |
  +--com.protomatter.jdbc.pool.JdbcConnectionPoolConnection
All Implemented Interfaces:
java.sql.Connection, ObjectPoolObject, SyslogChannelAware

public class JdbcConnectionPoolConnection
extends java.lang.Object
implements ObjectPoolObject, java.sql.Connection, SyslogChannelAware

A java.sql.Connection that's part of a pool of conections. When this connection is closed, it is checked back into the pool, and it's options like transaction isolation level, auto-commit, type map, etc are all reset to defaults.

See Also:
Connection, JdbcConnectionPoolDriver, JdbcConnectionPool

Field Summary
protected  java.sql.Connection connection
          The actual connection to the database.
protected  JdbcConnectionPool pool
          The pool that this connection is associated with.
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Method Summary
 void afterObjectPoolObjectCheckin()
          Used by the connection pool.
 void beforeObjectPoolObjectCheckout()
          Used by the connection pool.
 void clearWarnings()
          See java.sql.Connection.
 void close()
          Close the connection.
 void commit()
          See java.sql.Connection.
 java.sql.Statement createStatement()
          See java.sql.Connection.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency)
          See java.sql.Connection.
 void deleteObjectPoolObject()
          Used by the connection pool.
 boolean getAutoCommit()
          See java.sql.Connection.
 java.lang.String getCatalog()
          See java.sql.Connection.
 java.sql.Connection getConnection()
          Get the connection that this object wraps.
 JdbcConnectionPool getConnectionPool()
          Get the pool that this connection is associated with.
 java.sql.DatabaseMetaData getMetaData()
          See java.sql.Connection.
 java.lang.Object getSyslogChannel()
          Returns the channel information from the pool this connection is associated with.
 int getTransactionIsolation()
          See java.sql.Connection.
 java.util.Map getTypeMap()
          See java.sql.Connection.
 java.sql.SQLWarning getWarnings()
          See java.sql.Connection.
 void invalidate()
          Invalidates this connection manually.
 boolean isClosed()
          See java.sql.Connection.
 boolean isObjectPoolObjectValid()
          Used by the connection pool.
 boolean isReadOnly()
          See java.sql.Connection.
 java.lang.String nativeSQL(java.lang.String sql)
          See java.sql.Connection.
 java.sql.CallableStatement prepareCall(java.lang.String sql)
          See java.sql.Connection.
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          See java.sql.Connection.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          See java.sql.Connection.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          See java.sql.Connection.
 void refresh()
          Performs a non-verbose refresh.
 void refresh(boolean verbose)
          Will check that this connection is working and refresh it if not.
 void rollback()
          See java.sql.Connection.
 void setAutoCommit(boolean autoCommit)
          See java.sql.Connection.
 void setCatalog(java.lang.String catalog)
          See java.sql.Connection.
 void setReadOnly(boolean readOnly)
          See java.sql.Connection.
 void setTransactionIsolation(int level)
          See java.sql.Connection.
 void setTypeMap(java.util.Map typeMap)
          See java.sql.Connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pool

protected JdbcConnectionPool pool
The pool that this connection is associated with.

connection

protected java.sql.Connection connection
The actual connection to the database.
Method Detail

getConnectionPool

public JdbcConnectionPool getConnectionPool()
Get the pool that this connection is associated with.

getConnection

public java.sql.Connection getConnection()
Get the connection that this object wraps. This method should only be called if you really know what you're doing. This method exposes the connection that is actually connected to the database, but you should not really have any need to get ahold of it. This method will return null if you have called the close() method already.

getSyslogChannel

public java.lang.Object getSyslogChannel()
Returns the channel information from the pool this connection is associated with.
Specified by:
getSyslogChannel in interface SyslogChannelAware
See Also:
SyslogChannelAware

deleteObjectPoolObject

public void deleteObjectPoolObject()
Used by the connection pool.
Specified by:
deleteObjectPoolObject in interface ObjectPoolObject
See Also:
ObjectPoolObject

refresh

public void refresh(boolean verbose)
             throws java.sql.SQLException
Will check that this connection is working and refresh it if not. This executes the validity check statement that was set when the connection pool was created. If that statement was not set, the connection is refreshed no matter what. If the statement was set, it is executed and if an exception is generated, the connection is refreshed. If there's a problem refreshing the connection, this connection wrapper is invalidated -- you will have to either keep calling refresh() until it doesn't throw a SQLException, or call close() and open another connection using the JdbcConnectionPoolDriver. If verbose is true, messages are written to Syslog during the refresh operation.
Throws:
java.sql.SQLException - If the connection needs refreshing and there is a problem re-opening the connection.

refresh

public void refresh()
             throws java.sql.SQLException
Performs a non-verbose refresh.
See Also:
refresh(boolean)

isObjectPoolObjectValid

public boolean isObjectPoolObjectValid()
Used by the connection pool.
Specified by:
isObjectPoolObjectValid in interface ObjectPoolObject
See Also:
ObjectPoolObject

invalidate

public void invalidate()
Invalidates this connection manually. When this connection is closed, the pool will discard it.

beforeObjectPoolObjectCheckout

public void beforeObjectPoolObjectCheckout()
Used by the connection pool.
Specified by:
beforeObjectPoolObjectCheckout in interface ObjectPoolObject
See Also:
ObjectPoolObject

afterObjectPoolObjectCheckin

public void afterObjectPoolObjectCheckin()
Used by the connection pool.
Specified by:
afterObjectPoolObjectCheckin in interface ObjectPoolObject
See Also:
ObjectPoolObject

createStatement

public java.sql.Statement createStatement()
                                   throws java.sql.SQLException
See java.sql.Connection.
Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
See java.sql.Connection.
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                       throws java.sql.SQLException
See java.sql.Connection.
Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

nativeSQL

public java.lang.String nativeSQL(java.lang.String sql)
                           throws java.sql.SQLException
See java.sql.Connection.
Specified by:
nativeSQL in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws java.sql.SQLException
See java.sql.Connection.
Specified by:
setAutoCommit in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

getAutoCommit

public boolean getAutoCommit()
                      throws java.sql.SQLException
See java.sql.Connection.
Specified by:
getAutoCommit in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

commit

public void commit()
            throws java.sql.SQLException
See java.sql.Connection.
Specified by:
commit in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

rollback

public void rollback()
              throws java.sql.SQLException
See java.sql.Connection.
Specified by:
rollback in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

close

public void close()
           throws java.sql.SQLException
Close the connection. The underlying connection is checked back into the pool so it can be used by someone else. If this method completes without throwing a SQLException, then calling any method on this class (except this close() method) will throw a SQLException stating that the connection is closed. Repeatedly calling this method has no effect and will not throw exceptions (which some JDBC drivers do).

This method will call commit() on the connection if auto-commit is turned on, and will call rollback() otherwise.

Specified by:
close in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

isClosed

public boolean isClosed()
                 throws java.sql.SQLException
See java.sql.Connection.
Specified by:
isClosed in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                      throws java.sql.SQLException
See java.sql.Connection.
Specified by:
getMetaData in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws java.sql.SQLException
See java.sql.Connection.
Specified by:
setReadOnly in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

isReadOnly

public boolean isReadOnly()
                   throws java.sql.SQLException
See java.sql.Connection.
Specified by:
isReadOnly in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

setCatalog

public void setCatalog(java.lang.String catalog)
                throws java.sql.SQLException
See java.sql.Connection.
Specified by:
setCatalog in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

getCatalog

public java.lang.String getCatalog()
                            throws java.sql.SQLException
See java.sql.Connection.
Specified by:
getCatalog in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws java.sql.SQLException
See java.sql.Connection.
Specified by:
setTransactionIsolation in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

getTransactionIsolation

public int getTransactionIsolation()
                            throws java.sql.SQLException
See java.sql.Connection.
Specified by:
getTransactionIsolation in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
See java.sql.Connection.
Specified by:
getWarnings in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
See java.sql.Connection.
Specified by:
clearWarnings in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency)
                                   throws java.sql.SQLException
See java.sql.Connection.
Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

getTypeMap

public java.util.Map getTypeMap()
                         throws java.sql.SQLException
See java.sql.Connection.
Specified by:
getTypeMap in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int resultSetType,
                                              int resultSetConcurrency)
                                       throws java.sql.SQLException
See java.sql.Connection.
Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency)
                                            throws java.sql.SQLException
See java.sql.Connection.
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

setTypeMap

public void setTypeMap(java.util.Map typeMap)
                throws java.sql.SQLException
See java.sql.Connection.
Specified by:
setTypeMap in interface java.sql.Connection
Throws:
java.sql.SQLException - Because the underlying connection can throw one.
See Also:
Connection

Protomatter Software v1.1.8
Copyright 1998-2002 Nate Sammons

Protomatter Software v1.1.8 http://protomatter.sourceforge.net/1.1.8