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

📄 callablestatementwrapper.java

📁 mysql5.0 JDBC 驱动 放在glassfish或者tomcat的lib文件夹下就可以了
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* Copyright  2002-2007 MySQL AB, 2008 Sun Microsystems This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as  published by the Free Software Foundation. There are special exceptions to the terms and conditions of the GPL  as it is applied to this software. View the full text of the  exception in file EXCEPTIONS-CONNECTOR-J in the directory of this  software distribution. 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 java.io.InputStream;import java.io.Reader;import java.lang.reflect.Constructor;import java.math.BigDecimal;import java.net.URL;import java.sql.Array;import java.sql.Blob;import java.sql.CallableStatement;import java.sql.Clob;import java.sql.Date;import java.sql.Ref;import java.sql.SQLException;import java.sql.Time;import java.sql.Timestamp;import java.util.Calendar;import java.util.Map;import com.mysql.jdbc.SQLError;import com.mysql.jdbc.Util;/** * Wraps callable statements created by pooled connections. *  * @version $Id: CallableStatementWrapper.java,v 1.1.2.1 2005/05/13 18:58:38 *          mmatthews Exp $ */public class CallableStatementWrapper extends PreparedStatementWrapper		implements CallableStatement {private static final Constructor JDBC_4_CALLABLE_STATEMENT_WRAPPER_CTOR;		static {		if (Util.isJdbc4()) {			try {				JDBC_4_CALLABLE_STATEMENT_WRAPPER_CTOR = Class.forName(						"com.mysql.jdbc.jdbc2.optional.JDBC4CallableStatementWrapper").getConstructor(						new Class[] { ConnectionWrapper.class, 								MysqlPooledConnection.class, 								CallableStatement.class });			} catch (SecurityException e) {				throw new RuntimeException(e);			} catch (NoSuchMethodException e) {				throw new RuntimeException(e);			} catch (ClassNotFoundException e) {				throw new RuntimeException(e);			}		} else {			JDBC_4_CALLABLE_STATEMENT_WRAPPER_CTOR = null;		}	}		protected static CallableStatementWrapper getInstance(ConnectionWrapper c, 			MysqlPooledConnection conn,			CallableStatement toWrap) throws SQLException {		if (!Util.isJdbc4()) {			return new CallableStatementWrapper(c, 					conn, toWrap);		}		return (CallableStatementWrapper) Util.handleNewInstance(				JDBC_4_CALLABLE_STATEMENT_WRAPPER_CTOR,				new Object[] {c, 						conn, toWrap });	}		/**	 * @param c	 * @param conn	 * @param toWrap	 */	public CallableStatementWrapper(ConnectionWrapper c,			MysqlPooledConnection conn, CallableStatement toWrap) {		super(c, conn, toWrap);	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#registerOutParameter(int, int)	 */	public void registerOutParameter(int parameterIndex, int sqlType)			throws SQLException {		try {			if (this.wrappedStmt != null) {				((CallableStatement) this.wrappedStmt).registerOutParameter(						parameterIndex, sqlType);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#registerOutParameter(int, int, int)	 */	public void registerOutParameter(int parameterIndex, int sqlType, int scale)			throws SQLException {		try {			if (this.wrappedStmt != null) {				((CallableStatement) this.wrappedStmt).registerOutParameter(						parameterIndex, sqlType, scale);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#wasNull()	 */	public boolean wasNull() throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt).wasNull();			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return false;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getString(int)	 */	public String getString(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getString(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return null;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getBoolean(int)	 */	public boolean getBoolean(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getBoolean(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return false;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getByte(int)	 */	public byte getByte(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getByte(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return 0;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getShort(int)	 */	public short getShort(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getShort(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return 0;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getInt(int)	 */	public int getInt(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getInt(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return 0;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getLong(int)	 */	public long getLong(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getLong(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return 0;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getFloat(int)	 */	public float getFloat(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getFloat(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return 0;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getDouble(int)	 */	public double getDouble(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getDouble(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return 0;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getBigDecimal(int, int)	 */	public BigDecimal getBigDecimal(int parameterIndex, int scale)			throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt).getBigDecimal(						parameterIndex, scale);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return null;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getBytes(int)	 */	public byte[] getBytes(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getBytes(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return null;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getDate(int)	 */	public Date getDate(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getDate(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return null;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getTime(int)	 */	public Time getTime(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getTime(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return null;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getTimestamp(int)	 */	public Timestamp getTimestamp(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getTimestamp(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return null;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getObject(int)	 */	public Object getObject(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getObject(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}		} catch (SQLException sqlEx) {			checkAndFireConnectionError(sqlEx);		}		return null;	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.CallableStatement#getBigDecimal(int)	 */	public BigDecimal getBigDecimal(int parameterIndex) throws SQLException {		try {			if (this.wrappedStmt != null) {				return ((CallableStatement) this.wrappedStmt)						.getBigDecimal(parameterIndex);			} else {				throw SQLError.createSQLException(						"No operations allowed after statement closed",						SQLError.SQL_STATE_GENERAL_ERROR);			}

⌨️ 快捷键说明

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