?? connectionwrap.java
字號:
package com.ywh.dbcp;
/**
* <p>Title: greatom toolkit</p>
* <p>Description: db util</p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: 北京長通聯合寬帶網絡技術有限公司</p>
* @author zhengzp
* @version 1.0
*/
import java.sql.*;
import java.util.*;
/**
* 為實現Connection的回收,繼承并修改了數據庫連接
*/
public class ConnectionWrap implements java.sql.Connection {
public static boolean supportTransaction=true;
String _OwnerClassName;
ConnectionPool _poolOwner;
java.util.Date _usedDate;
java.sql.Connection conn;
/*重新定義的兩個方法*/
public ConnectionWrap(ConnectionPool pool,java.sql.Connection conn1){
_poolOwner=pool;
conn=conn1;
}
public void close() throws java.sql.SQLException{
if (supportTransaction) conn.commit();
_poolOwner.releaseConnection (this);
}
void setDate() {
_usedDate=new java.util.Date();
}
java.util.Date getDate() {
return(_usedDate);
}
public void setOwnerClassName(String cn) {
_OwnerClassName=cn;
}
public String getOwnerClassName() {
return (_OwnerClassName);
}
/* 以下的方法全部轉發*/
public void clearWarnings() throws SQLException{
conn.clearWarnings();
}
public void commit() throws SQLException{
if (supportTransaction) conn.commit();
}
public Statement createStatement() throws SQLException{
return (conn.createStatement());
}
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException{
return (conn.createStatement(resultSetType, resultSetConcurrency));
}
public boolean getAutoCommit() throws SQLException{
return (conn.getAutoCommit());
}
public String getCatalog() throws SQLException{
return (conn.getCatalog());
}
public DatabaseMetaData getMetaData() throws SQLException{
return (conn.getMetaData());
}
public int getTransactionIsolation() throws SQLException{
return (conn.getTransactionIsolation() );
}
public Map getTypeMap() throws SQLException{
return (conn.getTypeMap());
}
public SQLWarning getWarnings() throws SQLException{
return (conn.getWarnings());
}
public boolean isClosed() throws SQLException{
return (conn.isClosed());
}
public boolean isReadOnly() throws SQLException{
return (conn.isReadOnly());
}
public String nativeSQL(String sql) throws SQLException{
return (conn.nativeSQL(sql));
}
public CallableStatement prepareCall(String sql) throws SQLException{
return (conn.prepareCall(sql));
}
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException{
return (conn.prepareCall(sql, resultSetType, resultSetConcurrency));
}
public PreparedStatement prepareStatement(String sql) throws SQLException{
return (conn.prepareStatement(sql));
}
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException{
return (conn.prepareStatement(sql, resultSetType, resultSetConcurrency));
}
public void rollback() throws SQLException{
if (supportTransaction) conn.rollback();
}
public void setAutoCommit(boolean autoCommit) throws SQLException{
if (supportTransaction) conn.setAutoCommit(autoCommit);
}
public void setCatalog(String catalog) throws SQLException{
conn.setCatalog(catalog);
}
public void setReadOnly(boolean readOnly) throws SQLException{
conn.setReadOnly(readOnly);
}
public void setTransactionIsolation(int level) throws SQLException{
conn.setTransactionIsolation(level);
}
public void setTypeMap(Map map) throws SQLException{
conn.setTypeMap(map);
}
//------------------------For JDK1.4---------------------------
public void setHoldability(int holdability) throws SQLException
{
conn.setHoldability(holdability);
}
public int getHoldability() throws SQLException
{
return conn.getHoldability();
}
public Savepoint setSavepoint() throws SQLException
{
return conn.setSavepoint();
}
public Savepoint setSavepoint(String name) throws SQLException
{
return conn.setSavepoint(name);
}
public void rollback(Savepoint savepoint) throws SQLException
{
conn.rollback(savepoint);
}
public void releaseSavepoint(Savepoint savepoint) throws SQLException
{
conn.releaseSavepoint(savepoint);
}
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
{
return conn.createStatement(resultSetType,resultSetConcurrency,resultSetHoldability);
}
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
{
return conn.prepareStatement(sql,resultSetType,resultSetConcurrency,resultSetHoldability);
}
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
{
return conn.prepareCall(sql,resultSetType,resultSetConcurrency,resultSetHoldability);
}
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
{
return conn.prepareStatement(sql,autoGeneratedKeys);
}
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
{
return conn.prepareStatement(sql,columnIndexes);
}
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
{
return conn.prepareStatement(sql,columnNames);
}
/*------------------------For JDK1.4---------------------------*/
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -