📄 callablestatementproxy.java
字号:
//
//
package com.scxh.eei.sql.proxy;
import java.math.BigDecimal;
import java.sql.*;
import java.util.Calendar;
/**
* 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 callable statement with minimal overhead.
*
* @version $Id: CallableStatementProxy.java,v 1.3 2004/08/24 17:45:08 Exp $
*/
public class CallableStatementProxy extends PreparedStatementProxy implements CallableStatement {
private CallableStatement _callableStatement;
CallableStatementProxy(ConnectionProxy connection, CallableStatement callableStatement) {
super(connection, callableStatement);
_callableStatement = callableStatement;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {
validateConnection();
try {
_callableStatement.registerOutParameter(parameterIndex, sqlType);
//按顺序位置 parameterIndex 将 OUT 参数注册为 JDBC 类型 sqlType
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException {
validateConnection();
try {
_callableStatement.registerOutParameter(parameterIndex, sqlType, scale);
// scale - 小数点右边所需的位数。该参数必须大于或等于零。
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public boolean wasNull() throws SQLException {
validateConnection();
try {
return _callableStatement.wasNull();
//检索最后一个读取的 OUT 参数是否为 SQL NULL。若为 SQL NULL,则返回 true;否则返回 false
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return false;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public String getString(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getString(parameterIndex);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return null;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public boolean getBoolean(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getBoolean(parameterIndex);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return false;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public byte getByte(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getByte(parameterIndex);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return Byte.MIN_VALUE;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public short getShort(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getShort(parameterIndex);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return Short.MIN_VALUE;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public int getInt(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getInt(parameterIndex);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return Integer.MIN_VALUE;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public long getLong(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getLong(parameterIndex);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return Long.MIN_VALUE;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public float getFloat(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getFloat(parameterIndex);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return Float.MIN_VALUE;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public double getDouble(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getDouble(parameterIndex);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return Double.MIN_VALUE;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException {
validateConnection();
try {
return _callableStatement.getBigDecimal(parameterIndex, scale);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return null;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public byte[] getBytes(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getBytes(parameterIndex);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return null;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public Date getDate(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getDate(parameterIndex);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return null;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public Time getTime(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getTime(parameterIndex);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return null;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public Timestamp getTimestamp(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getTimestamp(parameterIndex);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return null;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public Object getObject(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getObject(parameterIndex);
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return null;
}
/**
* Delgates calls to the callable statement; SQLExceptions thrown from the
* callable statement will cause an event to be fired on the connection
* pool listeners.
*
* @throws SQLException if an error occurs
*/
public BigDecimal getBigDecimal(int parameterIndex) throws SQLException {
validateConnection();
try {
return _callableStatement.getBigDecimal(parameterIndex);
//全精度参数值。如果值为 SQL NULL,则结果为 null
} catch (SQLException sqlException) {
processSQLException(sqlException);
}
return null;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -