genericconnection.java
来自「这是一个轻便的j2ee的web应用框架,是一个在多个项目中运用的实际框架,采用s」· Java 代码 · 共 734 行 · 第 1/2 页
JAVA
734 行
* (JDBC 2.0) Create a Statement that will create a ResultSet of the
* specified type and concurrency.
*
* @param resultSetType A result set type
* @param resultSetConcurrency A result set concurrency
*
* @exception SQLException if a database access error occurs
*/
public Statement createStatement(int resultSetType,
int resultSetConcurrency)
throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
return (conn.createStatement(resultSetType, resultSetConcurrency));
}
/**
* Return the current auto-commit state.
*
* @exception SQLException if a database access error occurs
*/
public boolean getAutoCommit() throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
return (conn.getAutoCommit());
}
/**
* Return the current catalog name for this Connection.
*
* @exception SQLException if a database access error occurs
*/
public String getCatalog() throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
return (conn.getCatalog());
}
/**
* Get the metadata regarding this connection's database.
*
* @exception SQLException if a database access error occurs
*/
public DatabaseMetaData getMetaData() throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
return (conn.getMetaData());
}
/**
* Return this Connection's current transaction isolation level.
*
* @exception SQLException if a database access error occurs
*/
public int getTransactionIsolation() throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
return (conn.getTransactionIsolation());
}
/**
* (JDBC 2.0) Return the type map for this connection.
*
* @exception SQLException if a database access error occurs
*/
public Map getTypeMap() throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
return (conn.getTypeMap());
}
/**
* Return the first warning reported by calls to this Connection.
*
* @exception SQLException if a database access error occurs
*/
public SQLWarning getWarnings() throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
return (conn.getWarnings());
}
/**
* Return <code>true</code> 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.
*
* @exception SQLException if a database access error occurs
*/
public boolean isClosed() throws SQLException {
return (closed);
}
/**
* Return <code>true</code> if this Connection is in read-only mode.
*
* @exception SQLException if a database access error occurs
*/
public boolean isReadOnly() throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
return (conn.isReadOnly());
}
/**
* Convert the given SQL statement into the system's native SQL grammer.
*
* @param sql Statement to be processed
*/
public String nativeSQL(String sql) throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
return (conn.nativeSQL(sql));
}
/**
* Create a <code>CallableStatement</code> object for calling database
* stored procedures.
*
* @param sql Statement to be processed
*
* @exception SQLException if a database access error occurs
*/
public CallableStatement prepareCall(String sql) throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
return (conn.prepareCall(sql));
}
/**
* (JDBC 2.0) Create a CallableStatement object that will generate
* ResultSet objects with the given type and concurrency.
*
* @param sql Statement to be processed
* @param resultSetType A result set type
* @param resultSetConcurrency A result set concurrency
*
* @exception SQLException if a database access error occurs
*/
public CallableStatement prepareCall(String sql, int resultSetType,
int resultSetConcurrency)
throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
return (conn.prepareCall(sql, resultSetType, resultSetConcurrency));
}
/**
* Create a <code>PreparedStatement</code> object for sending
* parameterized SQL statements to the database.
*
* @param sql Statement to be processed
*
* @exception SQLException if a database access error occurs
*/
public PreparedStatement prepareStatement(String sql) throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
return (conn.prepareStatement(sql));
}
/**
* (JDBC 2.0) Create a PreparedStatement object that will generate
* ResultSet objects with the given type and concurrency.
*
* @param sql Statement to be processed
* @param resultSetType A result set type
* @param resultSetConcurrency A result set concurrency
*
* @exception SQLException if a database access error occurs
*/
public PreparedStatement prepareStatement(String sql, int resultSetType,
int resultSetConcurrency)
throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
return (conn.prepareStatement(sql, resultSetType,
resultSetConcurrency));
}
/**
* Drop all changes made since the previous commit or rollback.
*
* @exception SQLException if a database access error occurs
*/
public void rollback() throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
conn.rollback();
}
/**
* Sets this connection's auto-commit mode.
*
* @param autoCommit The new auto-commit mode.
*
* @exception SQLException if a database access error occurs
*/
public void setAutoCommit(boolean autoCommit) throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
conn.setAutoCommit(autoCommit);
}
/**
* Set the catalog name for this Connection.
*
* @param catalog The new catalog name
*
* @exception SQLException if a database access error occurs
*/
public void setCatalog(String catalog) throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
conn.setCatalog(catalog);
}
/**
* Set the read-only mode of this connection.
*
* @param readOnly The new read-only mode
*
* @exception SQLException if a database access error occurs
*/
public void setReadOnly(boolean readOnly) throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
conn.setReadOnly(readOnly);
}
/**
* Set the transaction isolation level for this Connection.
*
* @param level The new transaction isolation level
*
* @exception SQLException if a database access error occurs
*/
public void setTransactionIsolation(int level) throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
conn.setTransactionIsolation(level);
}
/**
* (JDBC 2.0) Set the type map for this connection.
*
* @param map The new type map
*
* @exception SQLException if a database access error occurs
*/
public void setTypeMap(Map map) throws SQLException {
if (closed) throw new SQLException(SQLEXCEPTION_CLOSED);
conn.setTypeMap(map);
}
// -------------------------------------------------------- Package Methods
/**
* Return the actual connection that we are wrapping.
*/
Connection getConnection() {
return (this.conn); // FIXME - Good idea to return if closed?
}
/**
* Return the data source that owns this connection.
*/
DataSource getDataSource() {
// Do not check for closed exception, to allow for a fresh connection
return (this.source);
}
/**
* 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.
*
*/
void setClosed(boolean closed) {
this.closed = closed;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?