org.apache.avalon.excalibur.datasource
Class JdbcConnection

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.avalon.excalibur.datasource.JdbcConnection
All Implemented Interfaces:
java.sql.Connection, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.logger.Loggable, Poolable, Recyclable

public class JdbcConnection
extends org.apache.avalon.framework.logger.AbstractLoggable
implements java.sql.Connection, Recyclable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable

The Connection object used in conjunction with the JdbcDataSource object. TODO: Implement a configurable closed end Pool, where the Connection acts like JDBC PooledConnections work. That means we can limit the total number of Connection objects that are created.

Since:
4.0
Version:
CVS $Revision: 1.4 $ $Date: 2001/08/07 10:57:07 $
Author:
Berin Loritsch

Field Summary
protected  java.sql.Connection m_connection
           
protected  int m_num_uses
           
protected  Pool m_pool
           
protected  java.sql.SQLException m_test_exception
           
protected  java.sql.PreparedStatement m_test_statement
           
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
JdbcConnection(java.sql.Connection connection, boolean oradb)
           
 
Method Summary
 void clearWarnings()
           
 void close()
           
 void commit()
           
 java.sql.Statement createStatement()
           
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency)
           
 void dispose()
           
 boolean getAutoCommit()
           
 java.lang.String getCatalog()
           
 java.sql.DatabaseMetaData getMetaData()
           
 int getTransactionIsolation()
           
 java.util.Map getTypeMap()
           
 java.sql.SQLWarning getWarnings()
           
 void initialize()
          Extend this for connection initialization--only needed for some drivers.
 boolean isClosed()
           
 boolean isReadOnly()
           
 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 resultSetType, int resultSetConcurrency)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
           
 void recycle()
          This method should be implemented to remove all costly resources in object.
 void rollback()
           
 void setAutoCommit(boolean autoCommit)
           
 void setCatalog(java.lang.String catalog)
           
 void setLogger(org.apache.log.Logger log)
           
protected  void setPool(Pool pool)
           
 void setReadOnly(boolean readOnly)
           
 void setTransactionIsolation(int level)
           
 void setTypeMap(java.util.Map map)
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_connection

protected java.sql.Connection m_connection

m_pool

protected Pool m_pool

m_test_statement

protected java.sql.PreparedStatement m_test_statement

m_test_exception

protected java.sql.SQLException m_test_exception

m_num_uses

protected int m_num_uses
Constructor Detail

JdbcConnection

public JdbcConnection(java.sql.Connection connection,
                      boolean oradb)
Method Detail

initialize

public void initialize()
Extend this for connection initialization--only needed for some drivers.
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable

setPool

protected void setPool(Pool pool)

setLogger

public final void setLogger(org.apache.log.Logger log)
Overrides:
setLogger in class org.apache.avalon.framework.logger.AbstractLoggable

createStatement

public final java.sql.Statement createStatement()
                                         throws java.sql.SQLException
Specified by:
createStatement in interface java.sql.Connection

prepareStatement

public final java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                                  throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection

prepareCall

public final java.sql.CallableStatement prepareCall(java.lang.String sql)
                                             throws java.sql.SQLException
Specified by:
prepareCall in interface java.sql.Connection

nativeSQL

public final java.lang.String nativeSQL(java.lang.String sql)
                                 throws java.sql.SQLException
Specified by:
nativeSQL in interface java.sql.Connection

setAutoCommit

public final void setAutoCommit(boolean autoCommit)
                         throws java.sql.SQLException
Specified by:
setAutoCommit in interface java.sql.Connection

getAutoCommit

public final boolean getAutoCommit()
                            throws java.sql.SQLException
Specified by:
getAutoCommit in interface java.sql.Connection

commit

public final void commit()
                  throws java.sql.SQLException
Specified by:
commit in interface java.sql.Connection

rollback

public final void rollback()
                    throws java.sql.SQLException
Specified by:
rollback in interface java.sql.Connection

close

public final void close()
                 throws java.sql.SQLException
Specified by:
close in interface java.sql.Connection

dispose

public final void dispose()
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable

recycle

public final void recycle()
Description copied from interface: Recyclable
This method should be implemented to remove all costly resources in object. These resources can be object references, database connections, threads etc. What is categorised as "costly" resources is determined on a case by case analysis.
Specified by:
recycle in interface Recyclable

isClosed

public final boolean isClosed()
                       throws java.sql.SQLException
Specified by:
isClosed in interface java.sql.Connection

getMetaData

public final java.sql.DatabaseMetaData getMetaData()
                                            throws java.sql.SQLException
Specified by:
getMetaData in interface java.sql.Connection

setReadOnly

public final void setReadOnly(boolean readOnly)
                       throws java.sql.SQLException
Specified by:
setReadOnly in interface java.sql.Connection

isReadOnly

public final boolean isReadOnly()
                         throws java.sql.SQLException
Specified by:
isReadOnly in interface java.sql.Connection

setCatalog

public final void setCatalog(java.lang.String catalog)
                      throws java.sql.SQLException
Specified by:
setCatalog in interface java.sql.Connection

getCatalog

public final java.lang.String getCatalog()
                                  throws java.sql.SQLException
Specified by:
getCatalog in interface java.sql.Connection

setTransactionIsolation

public final void setTransactionIsolation(int level)
                                   throws java.sql.SQLException
Specified by:
setTransactionIsolation in interface java.sql.Connection

getTransactionIsolation

public final int getTransactionIsolation()
                                  throws java.sql.SQLException
Specified by:
getTransactionIsolation in interface java.sql.Connection

getWarnings

public final java.sql.SQLWarning getWarnings()
                                      throws java.sql.SQLException
Specified by:
getWarnings in interface java.sql.Connection

clearWarnings

public final void clearWarnings()
                         throws java.sql.SQLException
Specified by:
clearWarnings in interface java.sql.Connection

createStatement

public final java.sql.Statement createStatement(int resultSetType,
                                                int resultSetConcurrency)
                                         throws java.sql.SQLException
Specified by:
createStatement in interface java.sql.Connection

prepareStatement

public final java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                         int resultSetType,
                                                         int resultSetConcurrency)
                                                  throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection

prepareCall

public final java.sql.CallableStatement prepareCall(java.lang.String sql,
                                                    int resultSetType,
                                                    int resultSetConcurrency)
                                             throws java.sql.SQLException
Specified by:
prepareCall in interface java.sql.Connection

getTypeMap

public final java.util.Map getTypeMap()
                               throws java.sql.SQLException
Specified by:
getTypeMap in interface java.sql.Connection

setTypeMap

public final void setTypeMap(java.util.Map map)
                      throws java.sql.SQLException
Specified by:
setTypeMap in interface java.sql.Connection


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.