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

📄 resultsetinpool.java

📁 国外的一套开源CRM
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*
 * Licensed under the X license (see http://www.x.org/terms.htm)
 */
package org.ofbiz.minerva.pool.jdbc;

import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;

/**
 * Wraps a result set to track the last used time for the owning connection.
 * That time is updated every time a navigation action is performed on the
 * result set (next, previous, etc.).
 *
 * @author Aaron Mulder (ammulder@alumni.princeton.edu)
 */
public class ResultSetInPool implements ResultSet {

    private final static String CLOSED = "ResultSet has been closed!";
    private ResultSet impl;
    private StatementInPool st;

    /**
     * Creates a new wrapper from a source result set and statement wrapper.
     */
    ResultSetInPool(ResultSet source, StatementInPool owner) {
        impl = source;
        st = owner;
    }

    /**
     * Updates the last used time for the owning connection to the current time.
     */
    public void setLastUsed() {
        st.setLastUsed();
    }

    /**
     * Indicates that an error occured on the owning statement.
     */
    public void setError(SQLException e) {
        if (st != null)
            st.setError(e);
    }

    /**
     * Gets a reference to the "real" ResultSet.  This should only be used if
     * you need to cast that to a specific type to call a proprietary method -
     * you will defeat all the pooling if you use the underlying ResultSet
     * directly.
     */
    public ResultSet getUnderlyingResultSet() {
        return impl;
    }

    // ---- Implementation of java.sql.ResultSet ----

    public boolean absolute(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        setLastUsed();
        try {
            return impl.absolute(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public void afterLast() throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        setLastUsed();
        try {
            impl.afterLast();
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public void beforeFirst() throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        setLastUsed();
        try {
            impl.beforeFirst();
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public void cancelRowUpdates() throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            impl.cancelRowUpdates();
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public void clearWarnings() throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            impl.clearWarnings();
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public void close() throws SQLException {
        if (impl != null) {
            try {
                impl.close();
            } catch (SQLException e) {
            }
            impl = null;
        }
        st = null;
    }

    public void deleteRow() throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        setLastUsed();
        try {
            impl.deleteRow();
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public int findColumn(String arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.findColumn(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public boolean first() throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        setLastUsed();
        try {
            return impl.first();
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public Array getArray(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getArray(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public Array getArray(String arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getArray(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public java.io.InputStream getAsciiStream(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getAsciiStream(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public java.io.InputStream getAsciiStream(String arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getAsciiStream(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public java.math.BigDecimal getBigDecimal(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getBigDecimal(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public java.math.BigDecimal getBigDecimal(int arg0, int arg1) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getBigDecimal(arg0, arg1);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public java.math.BigDecimal getBigDecimal(String arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getBigDecimal(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public java.math.BigDecimal getBigDecimal(String arg0, int arg1) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getBigDecimal(arg0, arg1);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public java.io.InputStream getBinaryStream(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getBinaryStream(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public java.io.InputStream getBinaryStream(String arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getBinaryStream(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public Blob getBlob(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getBlob(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public Blob getBlob(String arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getBlob(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public boolean getBoolean(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getBoolean(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public boolean getBoolean(String arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getBoolean(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public byte getByte(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getByte(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public byte getByte(String arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getByte(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public byte[] getBytes(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getBytes(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public byte[] getBytes(String arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getBytes(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public java.io.Reader getCharacterStream(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getCharacterStream(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public java.io.Reader getCharacterStream(String arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getCharacterStream(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public Clob getClob(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getClob(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public Clob getClob(String arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getClob(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public int getConcurrency() throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getConcurrency();
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public String getCursorName() throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getCursorName();
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public Date getDate(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getDate(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public Date getDate(int arg0, java.util.Calendar arg1) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getDate(arg0, arg1);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public Date getDate(String arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getDate(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public Date getDate(String arg0, java.util.Calendar arg1) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getDate(arg0, arg1);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public double getDouble(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getDouble(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public double getDouble(String arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getDouble(arg0);
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public int getFetchDirection() throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getFetchDirection();
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public int getFetchSize() throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {
            return impl.getFetchSize();
        } catch (SQLException e) {
            setError(e);
            throw e;
        }
    }

    public float getFloat(int arg0) throws SQLException {
        if (impl == null) throw new SQLException(CLOSED);
        try {

⌨️ 快捷键说明

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