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

📄 connectionproxy.java

📁 SAP这个系统的一个转换器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
//
//
package com.scxh.eei.sql.proxy;

import java.sql.*;
import java.util.Map;

import com.scxh.eei.sql.*;

/**
 * This class would be better implemented as a java.lang.reflect.Proxy.  However, this
 * feature was not added until 1.3 and reflection performance was not improved until 1.4.
 * Since the driver still needs to be compatible with 1.2 and 1.3 this class is used
 * to delegate the calls to the connection with minimal overhead.
 *
 * @version $Id: ConnectionProxy.java,v 1.6 2004/12/06 12:10:31 Exp $
 */
public class ConnectionProxy implements Connection {
    private com.scxh.eei.sql.PooledConnection _pooledConnection;
    private Connection _connection;
    private boolean _closed = false;

    /**
     * Constructs a new connection proxy.
     */
    public ConnectionProxy(com.scxh.eei.sql.PooledConnection pooledConnection,
                           Connection connection) {
        _pooledConnection = pooledConnection;
        _connection = (Connection) connection;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public void clearWarnings() throws SQLException {
        validateConnection();

        try {
            _connection.clearWarnings();
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     */
    public void close() {
        if (_closed) {
            return;
        }

        _pooledConnection.fireConnectionEvent(true, null);
        _closed = true;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public void commit() throws SQLException {
        validateConnection();

        try {
            _connection.commit();
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public Statement createStatement() throws SQLException {
        validateConnection();

        try {
            return new StatementProxy(this, _connection.createStatement());
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return null;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
        validateConnection();

        try {
            return new StatementProxy(this, _connection.createStatement(resultSetType, resultSetConcurrency));
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return null;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
        validateConnection();

        try {
            return new StatementProxy(this, _connection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability));
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return null;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public boolean getAutoCommit() throws SQLException {
        validateConnection();

        try {
            return _connection.getAutoCommit();
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return false;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public String getCatalog() throws SQLException {
        validateConnection();

        try {
            return _connection.getCatalog();
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return null;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public int getHoldability() throws SQLException {
        validateConnection();

        try {
            return _connection.getHoldability();
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return Integer.MIN_VALUE;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public int getTransactionIsolation() throws SQLException {
        validateConnection();

        try {
            return _connection.getTransactionIsolation();
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return Integer.MIN_VALUE;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public Map getTypeMap() throws SQLException {
        validateConnection();

        try {
            return _connection.getTypeMap();
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return null;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public SQLWarning getWarnings() throws SQLException {
        validateConnection();

        try {
            return _connection.getWarnings();
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return null;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public DatabaseMetaData getMetaData() throws SQLException {
        validateConnection();

        try {
            return _connection.getMetaData();
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return null;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public boolean isClosed() throws SQLException {
        if (_closed) {
            return true;
        }

        try {
            return _connection.isClosed();
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return _closed;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public boolean isReadOnly() throws SQLException {
        validateConnection();

        try {
            return _connection.isReadOnly();
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return false;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public String nativeSQL(String sql) throws SQLException {
        validateConnection();

        try {
            return _connection.nativeSQL(sql);
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return null;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public CallableStatement prepareCall(String sql) throws SQLException {
        validateConnection();

        try {
            return new CallableStatementProxy(this, _connection.prepareCall(sql));
        } catch (SQLException sqlException) {
            processSQLException(sqlException);
        }

        return null;
    }

    /**
     * Delgates calls to the connection; SQLExceptions thrown from the connection
     * will cause an event to be fired on the connection pool listeners.
     *
     * @throws SQLException if an error occurs
     */
    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
        validateConnection();

        try {
            return new CallableStatementProxy(this,  _connection.prepareCall(sql, resultSetType, resultSetConcurrency));
        } catch (SQLException sqlException) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -