📄 statementproxy.java
字号:
//
//
package com.scxh.eei.sql.proxy;
import java.sql.*;
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 a statement with minimal overhead.
*
* @version $Id: StatementProxy.java,v 1.4 2004/08/24 17:45:08 Exp $
*/
public class StatementProxy implements Statement {
private ConnectionProxy _connection;
private Statement _statement;
StatementProxy(ConnectionProxy connection, Statement statement) {
_connection = connection;
_statement = statement;
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public ResultSet executeQuery(String sql) throws SQLException {
validateConnection();
try {
return _statement.executeQuery(sql);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return null;
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public int executeUpdate(String sql) throws SQLException {
validateConnection();
try {
return _statement.executeUpdate(sql);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return Integer.MIN_VALUE;
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public void close() throws SQLException {
validateConnection();
try {
_statement.close();
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public int getMaxFieldSize() throws SQLException {
validateConnection();
try {
return _statement.getMaxFieldSize();
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return Integer.MIN_VALUE;
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public void setMaxFieldSize(int max) throws SQLException {
validateConnection();
try {
_statement.setMaxFieldSize(max);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public int getMaxRows() throws SQLException {
validateConnection();
try {
return _statement.getMaxRows();
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return Integer.MIN_VALUE;
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public void setMaxRows(int max) throws SQLException {
validateConnection();
try {
_statement.setMaxRows(max);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public void setEscapeProcessing(boolean enable) throws SQLException {
validateConnection();
try {
_statement.setEscapeProcessing(enable);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public int getQueryTimeout() throws SQLException {
validateConnection();
try {
return _statement.getQueryTimeout();
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return Integer.MIN_VALUE;
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public void setQueryTimeout(int seconds) throws SQLException {
validateConnection();
try {
_statement.setQueryTimeout(seconds);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public void cancel() throws SQLException {
validateConnection();
try {
_statement.cancel();
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* 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 _statement.getWarnings();
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return null;
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* 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 {
_statement.clearWarnings();
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public void setCursorName(String name) throws SQLException {
validateConnection();
try {
_statement.setCursorName(name);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public boolean execute(String sql) throws SQLException {
validateConnection();
try {
return _statement.execute(sql);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return false;
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public ResultSet getResultSet() throws SQLException {
validateConnection();
try {
return _statement.getResultSet();
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return null;
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public int getUpdateCount() throws SQLException {
validateConnection();
try {
return _statement.getUpdateCount();
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return Integer.MIN_VALUE;
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public boolean getMoreResults() throws SQLException {
validateConnection();
try {
return _statement.getMoreResults();
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return false;
}
/**
* Delgates calls to the statement; SQLExceptions thrown from the statement
* will cause an event to be fired on the connection pool listeners.
*
* @throws SQLException if an error occurs
*/
public void setFetchDirection(int direction) throws SQLException {
validateConnection();
try {
_statement.setFetchDirection(direction);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -