⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connectionwrap.java

📁 采用JAVA开发
💻 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 + -