?? preparedstatementwrapper.java
字號:
/*
Copyright (C) 2004 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.mysql.jdbc.jdbc2.optional;
import com.mysql.jdbc.SQLError;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.ParameterMetaData;
import java.sql.PreparedStatement;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;
/**
* Wraps prepared statements so that errors can be reported correctly to
* ConnectionEventListeners.
*
* @author Mark Matthews
*
* @version $Id: PreparedStatementWrapper.java,v 1.1.2.1 2004/02/13 17:55:30 mmatthew Exp $
*/
class PreparedStatementWrapper extends StatementWrapper
implements PreparedStatement {
PreparedStatementWrapper(MysqlPooledConnection conn,
PreparedStatement toWrap) {
super(conn, toWrap);
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setArray(int, java.sql.Array)
*/
public void setArray(int parameterIndex, Array x) throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setArray(parameterIndex,
x);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream, int)
*/
public void setAsciiStream(int parameterIndex, InputStream x, int length)
throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setAsciiStream(parameterIndex,
x, length);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setBigDecimal(int, java.math.BigDecimal)
*/
public void setBigDecimal(int parameterIndex, BigDecimal x)
throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setBigDecimal(parameterIndex,
x);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream, int)
*/
public void setBinaryStream(int parameterIndex, InputStream x, int length)
throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setBinaryStream(parameterIndex,
x, length);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setBlob(int, java.sql.Blob)
*/
public void setBlob(int parameterIndex, Blob x) throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setBlob(parameterIndex, x);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setBoolean(int, boolean)
*/
public void setBoolean(int parameterIndex, boolean x)
throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setBoolean(parameterIndex,
x);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setByte(int, byte)
*/
public void setByte(int parameterIndex, byte x) throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setByte(parameterIndex, x);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setBytes(int, byte[])
*/
public void setBytes(int parameterIndex, byte[] x)
throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setBytes(parameterIndex,
x);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, int)
*/
public void setCharacterStream(int parameterIndex, Reader reader, int length)
throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setCharacterStream(parameterIndex,
reader, length);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setClob(int, java.sql.Clob)
*/
public void setClob(int parameterIndex, Clob x) throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setClob(parameterIndex, x);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setDate(int, java.sql.Date)
*/
public void setDate(int parameterIndex, Date x) throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setDate(parameterIndex, x);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setDate(int, java.sql.Date, java.util.Calendar)
*/
public void setDate(int parameterIndex, Date x, Calendar cal)
throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setDate(parameterIndex,
x, cal);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setDouble(int, double)
*/
public void setDouble(int parameterIndex, double x)
throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setDouble(parameterIndex,
x);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setFloat(int, float)
*/
public void setFloat(int parameterIndex, float x) throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setFloat(parameterIndex,
x);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setInt(int, int)
*/
public void setInt(int parameterIndex, int x) throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setInt(parameterIndex, x);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setLong(int, long)
*/
public void setLong(int parameterIndex, long x) throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setLong(parameterIndex, x);
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#getMetaData()
*/
public ResultSetMetaData getMetaData() throws SQLException {
try {
if (this.wrappedStmt != null) {
return ((PreparedStatement) this.wrappedStmt).getMetaData();
} else {
throw new SQLException("No operations allowed after statement closed",
SQLError.SQL_STATE_GENERAL_ERROR);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return null;
}
/* (non-Javadoc)
* @see java.sql.PreparedStatement#setNull(int, int)
*/
public void setNull(int parameterIndex, int sqlType)
throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setNull(parameterIndex,
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -