Apache Struts API Documentation: Class GenericConnection

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts.util
Class GenericConnection

    java.lang.Object
      |
      +--org.apache.struts.util.GenericConnection

All Implemented Interfaces:
  java.sql.Connection

public class GenericConnection
extends java.lang.Object
implements java.sql.Connection

Generic wrapper implementation of a Connection that works with `GenericDataSource` to wrap connections for any JDBC driver.

Version:
  $Revision: 1.1 $ $Date: 2001-09-17 21:13:30 +0100 (Mon, 17 Sep 2001) $
Author:
  Craig R. McClanahan, Ted Husted

Field Summary
`protected boolean` | `autoCommit` The initial auto-commit state to which we should return after release.
`protected java.lang.String` | `catalog` The initial catalog to which we should return after release.
`private boolean` | `closed` The closed flag for this wrapped connection.
`protected java.sql.Connection` | `conn` The Connection that is being wrapped.
`protected int` | `level` The initial transaction isolation level to which we should return after release.
`protected java.util.Map` | `map` The initial type map to which we should return after release.
`protected boolean` | `readOnly` The initial read-only state to which we should return after release.
`protected GenericDataSource` | `source` The GenericDataSource that owns this connection.
`private static java.lang.String` | `SQLEXCEPTION_CLOSED`

Fields inherited from interface java.sql.Connection
`TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE`

Constructor Summary
`GenericConnection(GenericDataSource source, java.sql.Connection conn, boolean autoCommit, boolean readOnly)` Construct a new GenericConnection wrapping the specified connection.

Method Summary
`void` | `clearWarnings()` Clear all warnings reported for this Connection.
`void` | `close()` Return this wrapped Connection to our data source connection pool.
`void` | `commit()` Make all changes made since the previous commit or rollback permanent, and releases any database locks currently held.
`java.sql.Statement` | `createStatement()` Create a `Statement` for sending SQL statements to the database.
`java.sql.Statement` | `createStatement(int resultSetType, int resultSetConcurrency)` (JDBC 2.0) Create a Statement that will create a ResultSet of the specified type and concurrency.
`boolean` | `getAutoCommit()` Return the current auto-commit state.
`java.lang.String` | `getCatalog()` Return the current catalog name for this Connection.
`(package private) java.sql.Connection` | `getConnection()` Return the actual connection that we are wrapping.
`(package private) javax.sql.DataSource` | `getDataSource()` Return the data source that owns this connection.
`java.sql.DatabaseMetaData` | `getMetaData()` Get the metadata regarding this connection's database.
`int` | `getTransactionIsolation()` Return this Connection's current transaction isolation level.
`java.util.Map` | `getTypeMap()` (JDBC 2.0) Return the type map for this connection.
`java.sql.SQLWarning` | `getWarnings()` Return the first warning reported by calls to this Connection.
`boolean` | `isClosed()` Return `true` if this Connection is closed.
`boolean` | `isReadOnly()` Return `true` if this Connection is in read-only mode.
`java.lang.String` | `nativeSQL(java.lang.String sql)` Convert the given SQL statement into the system's native SQL grammer.
`java.sql.CallableStatement` | `prepareCall(java.lang.String sql)` Create a `CallableStatement` object for calling database stored procedures.
`java.sql.CallableStatement` | `prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)` (JDBC 2.0) Create a CallableStatement object that will generate ResultSet objects with the given type and concurrency.
`java.sql.PreparedStatement` | `prepareStatement(java.lang.String sql)` Create a `PreparedStatement` object for sending parameterized SQL statements to the database.
`java.sql.PreparedStatement` | `prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)` (JDBC 2.0) Create a PreparedStatement object that will generate ResultSet objects with the given type and concurrency.
`void` | `rollback()` Drop all changes made since the previous commit or rollback.
`void` | `setAutoCommit(boolean autoCommit)` Sets this connection's auto-commit mode.
`void` | `setCatalog(java.lang.String catalog)` Set the catalog name for this Connection.
`(package private) void` | `setClosed(boolean closed)` Set the closed status of this connection wrapper.
`void` | `setReadOnly(boolean readOnly)` Set the read-only mode of this connection.
`void` | `setTransactionIsolation(int level)` Set the transaction isolation level for this Connection.
`void` | `setTypeMap(java.util.Map map)` (JDBC 2.0) Set the type map for this connection.

Methods inherited from class java.lang.Object
`, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait`

Field Detail

### SQLEXCEPTION_CLOSED

    private static final java.lang.String SQLEXCEPTION_CLOSED

### autoCommit

    protected boolean autoCommit

  The initial auto-commit state to which we should return after release.

### catalog

    protected java.lang.String catalog

  The initial catalog to which we should return after release.

### closed

    private boolean closed

  The closed flag for this wrapped connection.

### conn

    protected java.sql.Connection conn

  The Connection that is being wrapped.

### level

    protected int level

  The initial transaction isolation level to which we should return after release.

### map

    protected java.util.Map map

  The initial type map to which we should return after release.

### readOnly

    protected boolean readOnly

  The initial read-only state to which we should return after release.

### source

    protected GenericDataSource source

  The GenericDataSource that owns this connection.

Constructor Detail

### GenericConnection

    public GenericConnection(GenericDataSource source,
                             java.sql.Connection conn,
                             boolean autoCommit,
                             boolean readOnly)
                      throws java.sql.SQLException

  Construct a new GenericConnection wrapping the specified connection.
  Parameters:
    `source` - The data source that owns this connection
    `conn` - The connection to wrap
    `autoCommit` - Desired auto-commit state for this connection
    `readOnly` - Desired read-only state for this connection
  Throws:
    `java.sql.SQLException` - if an SQL processing error occurs

Method Detail

### clearWarnings

    public void clearWarnings()
                       throws java.sql.SQLException

  Clear all warnings reported for this Connection.
  Specified by:
    `clearWarnings` in interface `java.sql.Connection`
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### close

    public void close()
               throws java.sql.SQLException

  Return this wrapped Connection to our data source connection pool.
  Specified by:
    `close` in interface `java.sql.Connection`
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### commit

    public void commit()
                throws java.sql.SQLException

  Make all changes made since the previous commit or rollback permanent, and releases any database locks currently held.
  Specified by:
    `commit` in interface `java.sql.Connection`
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### createStatement

    public java.sql.Statement createStatement()
                                       throws java.sql.SQLException

  Create a `Statement` for sending SQL statements to the database.
  Specified by:
    `createStatement` in interface `java.sql.Connection`
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### createStatement

    public java.sql.Statement createStatement(int resultSetType,
                                              int resultSetConcurrency)
                                       throws java.sql.SQLException

  (JDBC 2.0) Create a Statement that will create a ResultSet of the specified type and concurrency.
  Specified by:
    `createStatement` in interface `java.sql.Connection`
  Parameters:
    `resultSetType` - A result set type
    `resultSetConcurrency` - A result set concurrency
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### getAutoCommit

    public boolean getAutoCommit()
                          throws java.sql.SQLException

  Return the current auto-commit state.
  Specified by:
    `getAutoCommit` in interface `java.sql.Connection`
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### getCatalog

    public java.lang.String getCatalog()
                                throws java.sql.SQLException

  Return the current catalog name for this Connection.
  Specified by:
    `getCatalog` in interface `java.sql.Connection`
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### getMetaData

    public java.sql.DatabaseMetaData getMetaData()
                                          throws java.sql.SQLException

  Get the metadata regarding this connection's database.
  Specified by:
    `getMetaData` in interface `java.sql.Connection`
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### getTransactionIsolation

    public int getTransactionIsolation()
                                throws java.sql.SQLException

  Return this Connection's current transaction isolation level.
  Specified by:
    `getTransactionIsolation` in interface `java.sql.Connection`
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### getTypeMap

    public java.util.Map getTypeMap()
                             throws java.sql.SQLException

  (JDBC 2.0) Return the type map for this connection.
  Specified by:
    `getTypeMap` in interface `java.sql.Connection`
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### getWarnings

    public java.sql.SQLWarning getWarnings()
                                    throws java.sql.SQLException

  Return the first warning reported by calls to this Connection.
  Specified by:
    `getWarnings` in interface `java.sql.Connection`
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### isClosed

    public boolean isClosed()
                     throws java.sql.SQLException

  Return `true` if this Connection is closed. The GenericConnection.isClosed() method is only guaranteed to return true after GenericConnection.closed() has been called. This method cannot be called, in general, to determine if a database connection is valid or invalid. A typical JDBC client can determine that a connection is invalid by catching the exception that is thrown when a JDBC operation is attempted.
  Specified by:
    `isClosed` in interface `java.sql.Connection`
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### isReadOnly

    public boolean isReadOnly()
                       throws java.sql.SQLException

  Return `true` if this Connection is in read-only mode.
  Specified by:
    `isReadOnly` in interface `java.sql.Connection`
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### nativeSQL

    public java.lang.String nativeSQL(java.lang.String sql)
                               throws java.sql.SQLException

  Convert the given SQL statement into the system's native SQL grammer.
  Specified by:
    `nativeSQL` in interface `java.sql.Connection`
  Parameters:
    `sql` - Statement to be processed

### prepareCall

    public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                           throws java.sql.SQLException

  Create a `CallableStatement` object for calling database stored procedures.
  Specified by:
    `prepareCall` in interface `java.sql.Connection`
  Parameters:
    `sql` - Statement to be processed
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### prepareCall

    public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                                  int resultSetType,
                                                  int resultSetConcurrency)
                                           throws java.sql.SQLException

  (JDBC 2.0) Create a CallableStatement object that will generate ResultSet objects with the given type and concurrency.
  Specified by:
    `prepareCall` in interface `java.sql.Connection`
  Parameters:
    `sql` - Statement to be processed
    `resultSetType` - A result set type
    `resultSetConcurrency` - A result set concurrency
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### prepareStatement

    public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                                throws java.sql.SQLException

  Create a `PreparedStatement` object for sending parameterized SQL statements to the database.
  Specified by:
    `prepareStatement` in interface `java.sql.Connection`
  Parameters:
    `sql` - Statement to be processed
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### prepareStatement

    public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                       int resultSetType,
                                                       int resultSetConcurrency)
                                                throws java.sql.SQLException

  (JDBC 2.0) Create a PreparedStatement object that will generate ResultSet objects with the given type and concurrency.
  Specified by:
    `prepareStatement` in interface `java.sql.Connection`
  Parameters:
    `sql` - Statement to be processed
    `resultSetType` - A result set type
    `resultSetConcurrency` - A result set concurrency
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### rollback

    public void rollback()
                  throws java.sql.SQLException

  Drop all changes made since the previous commit or rollback.
  Specified by:
    `rollback` in interface `java.sql.Connection`
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### setAutoCommit

    public void setAutoCommit(boolean autoCommit)
                       throws java.sql.SQLException

  Sets this connection's auto-commit mode.
  Specified by:
    `setAutoCommit` in interface `java.sql.Connection`
  Parameters:
    `autoCommit` - The new auto-commit mode.
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### setCatalog

    public void setCatalog(java.lang.String catalog)
                    throws java.sql.SQLException

  Set the catalog name for this Connection.
  Specified by:
    `setCatalog` in interface `java.sql.Connection`
  Parameters:
    `catalog` - The new catalog name
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### setReadOnly

    public void setReadOnly(boolean readOnly)
                     throws java.sql.SQLException

  Set the read-only mode of this connection.
  Specified by:
    `setReadOnly` in interface `java.sql.Connection`
  Parameters:
    `readOnly` - The new read-only mode
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### setTransactionIsolation

    public void setTransactionIsolation(int level)
                                 throws java.sql.SQLException

  Set the transaction isolation level for this Connection.
  Specified by:
    `setTransactionIsolation` in interface `java.sql.Connection`
  Parameters:
    `level` - The new transaction isolation level
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### setTypeMap

    public void setTypeMap(java.util.Map map)
                    throws java.sql.SQLException

  (JDBC 2.0) Set the type map for this connection.
  Specified by:
    `setTypeMap` in interface `java.sql.Connection`
  Parameters:
    `map` - The new type map
  Throws:
    `java.sql.SQLException` - if a database access error occurs

### getConnection

    java.sql.Connection getConnection()

  Return the actual connection that we are wrapping.

### getDataSource

    javax.sql.DataSource getDataSource()

  Return the data source that owns this connection.

### setClosed

    void setClosed(boolean closed)

  Set the closed status of this connection wrapper. Would usually only be called by the owning DataSource (source), with setClosed(false), when a pooled connection is being recycled.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2001 - Apache Software Foundation