|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.struts.util.GenericConnection
Generic wrapper implementation of a Connection that
works with GenericDataSource
to wrap connections for any
JDBC driver.
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 |
|
Field Detail |
private static final java.lang.String SQLEXCEPTION_CLOSED
protected boolean autoCommit
protected java.lang.String catalog
private boolean closed
protected java.sql.Connection conn
protected int level
protected java.util.Map map
protected boolean readOnly
protected GenericDataSource source
Constructor Detail |
public GenericConnection(GenericDataSource source, java.sql.Connection conn, boolean autoCommit, boolean readOnly) throws java.sql.SQLException
source
- The data source that owns this connectionconn
- The connection to wrapautoCommit
- Desired auto-commit state for this connectionreadOnly
- Desired read-only state for this connectionjava.sql.SQLException
- if an SQL processing error occursMethod Detail |
public void clearWarnings() throws java.sql.SQLException
clearWarnings
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic void close() throws java.sql.SQLException
close
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic void commit() throws java.sql.SQLException
commit
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic java.sql.Statement createStatement() throws java.sql.SQLException
Statement
for sending SQL statements to the
database.createStatement
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
createStatement
in interface java.sql.Connection
resultSetType
- A result set typeresultSetConcurrency
- A result set concurrencyjava.sql.SQLException
- if a database access error occurspublic boolean getAutoCommit() throws java.sql.SQLException
getAutoCommit
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic java.lang.String getCatalog() throws java.sql.SQLException
getCatalog
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException
getMetaData
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic int getTransactionIsolation() throws java.sql.SQLException
getTransactionIsolation
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic java.util.Map getTypeMap() throws java.sql.SQLException
getTypeMap
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic java.sql.SQLWarning getWarnings() throws java.sql.SQLException
getWarnings
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic boolean isClosed() throws java.sql.SQLException
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.isClosed
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic boolean isReadOnly() throws java.sql.SQLException
true
if this Connection is in read-only mode.isReadOnly
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic java.lang.String nativeSQL(java.lang.String sql) throws java.sql.SQLException
nativeSQL
in interface java.sql.Connection
sql
- Statement to be processedpublic java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException
CallableStatement
object for calling database
stored procedures.prepareCall
in interface java.sql.Connection
sql
- Statement to be processedjava.sql.SQLException
- if a database access error occurspublic java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
sql
- Statement to be processedresultSetType
- A result set typeresultSetConcurrency
- A result set concurrencyjava.sql.SQLException
- if a database access error occurspublic java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
PreparedStatement
object for sending
parameterized SQL statements to the database.prepareStatement
in interface java.sql.Connection
sql
- Statement to be processedjava.sql.SQLException
- if a database access error occurspublic java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
sql
- Statement to be processedresultSetType
- A result set typeresultSetConcurrency
- A result set concurrencyjava.sql.SQLException
- if a database access error occurspublic void rollback() throws java.sql.SQLException
rollback
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic void setAutoCommit(boolean autoCommit) throws java.sql.SQLException
setAutoCommit
in interface java.sql.Connection
autoCommit
- The new auto-commit mode.java.sql.SQLException
- if a database access error occurspublic void setCatalog(java.lang.String catalog) throws java.sql.SQLException
setCatalog
in interface java.sql.Connection
catalog
- The new catalog namejava.sql.SQLException
- if a database access error occurspublic void setReadOnly(boolean readOnly) throws java.sql.SQLException
setReadOnly
in interface java.sql.Connection
readOnly
- The new read-only modejava.sql.SQLException
- if a database access error occurspublic void setTransactionIsolation(int level) throws java.sql.SQLException
setTransactionIsolation
in interface java.sql.Connection
level
- The new transaction isolation leveljava.sql.SQLException
- if a database access error occurspublic void setTypeMap(java.util.Map map) throws java.sql.SQLException
setTypeMap
in interface java.sql.Connection
map
- The new type mapjava.sql.SQLException
- if a database access error occursjava.sql.Connection getConnection()
javax.sql.DataSource getDataSource()
void setClosed(boolean closed)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |