📄 callablestatement.java
字号:
/* Copyright (C) 2002-2004 MySQL AB 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;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.Ref;import java.sql.SQLException;import java.sql.Time;import java.sql.Timestamp;import java.sql.Types;import java.util.ArrayList;import java.util.Calendar;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Locale;import java.util.Map;/** * Representation of stored procedures for JDBC * * @author Mark Matthews * @version $Id: CallableStatement.java,v 1.1.2.24 2005/02/07 21:07:31 mmatthew Exp $ */public class CallableStatement extends PreparedStatement implements java.sql.CallableStatement { private final static int NOT_OUTPUT_PARAMETER_INDICATOR = Integer.MIN_VALUE; protected CallableStatementParamInfo paramInfo; //private List parameterList; //private Map parameterMap; private ResultSet outputParameterResults; private int[] parameterIndexToRsIndex; private boolean hasOutputParams = false; /** * Creates a new CallableStatement * * @param conn the connection creating this statement * @param sql the SQL to prepare * @param catalog the current catalog * * @throws SQLException if an error occurs */ public CallableStatement(Connection conn, String sql, String catalog) throws SQLException { super(conn, conn.nativeSQL(sql), catalog); determineParameterTypes(); } /** * Creates a new CallableStatement * * @param conn the connection creating this statement * @param paramInfo the SQL to prepare * * @throws SQLException if an error occurs */ public CallableStatement(Connection conn, CallableStatementParamInfo paramInfo) throws SQLException { super(conn, paramInfo.nativeSql, paramInfo.catalogInUse); this.paramInfo = paramInfo; } /** * Creates a new CallableStatement * * @param conn the connection creating this statement * @param catalog catalog the current catalog * * @throws SQLException if an error occurs */ public CallableStatement(Connection conn, String catalog) throws SQLException { super(conn, catalog, null); determineParameterTypes(); } /** * @see java.sql.CallableStatement#getArray(int) */ public Array getArray(int i) throws SQLException { return getOutputParameters().getArray(mapOutputParameterIndexToRsIndex( i)); } /** * @see java.sql.CallableStatement#getArray(java.lang.String) */ public Array getArray(String parameterName) throws SQLException { return getOutputParameters().getArray(fixParameterName(parameterName)); } /** * @see java.sql.CallableStatement#setAsciiStream(java.lang.String, * java.io.InputStream, int) */ public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException { setAsciiStream(getNamedParamIndex(parameterName, false), x, length); } /** * @see java.sql.CallableStatement#setBigDecimal(java.lang.String, * java.math.BigDecimal) */ public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException { setBigDecimal(getNamedParamIndex(parameterName, false), x); } /** * DOCUMENT ME! * * @param parameterIndex DOCUMENT ME! * @param scale DOCUMENT ME! * * @return DOCUMENT ME! * * @throws SQLException DOCUMENT ME! * * @see java.sql.CallableStatement#getBigDecimal(int, int) * @deprecated */ public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException { return getOutputParameters().getBigDecimal(mapOutputParameterIndexToRsIndex( parameterIndex), scale); } /** * @see java.sql.CallableStatement#getBigDecimal(int) */ public BigDecimal getBigDecimal(int parameterIndex) throws SQLException { return getOutputParameters().getBigDecimal(mapOutputParameterIndexToRsIndex( parameterIndex)); } /** * @see java.sql.CallableStatement#getBigDecimal(java.lang.String) */ public BigDecimal getBigDecimal(String parameterName) throws SQLException { return getOutputParameters().getBigDecimal(fixParameterName( parameterName)); } /** * @see java.sql.CallableStatement#setBinaryStream(java.lang.String, * java.io.InputStream, int) */ public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException { setBinaryStream(getNamedParamIndex(parameterName, false), x, length); } /** * @see java.sql.CallableStatement#getBlob(int) */ public Blob getBlob(int parameterIndex) throws SQLException { return getOutputParameters().getBlob(mapOutputParameterIndexToRsIndex( parameterIndex)); } /** * @see java.sql.CallableStatement#getBlob(java.lang.String) */ public Blob getBlob(String parameterName) throws SQLException { return getOutputParameters().getBlob(fixParameterName(parameterName)); } /** * @see java.sql.CallableStatement#setBoolean(java.lang.String, boolean) */ public void setBoolean(String parameterName, boolean x) throws SQLException { setBoolean(getNamedParamIndex(parameterName, false), x); } /** * @see java.sql.CallableStatement#getBoolean(int) */ public boolean getBoolean(int parameterIndex) throws SQLException { return getOutputParameters().getBoolean(mapOutputParameterIndexToRsIndex( parameterIndex)); } /** * @see java.sql.CallableStatement#getBoolean(java.lang.String) */ public boolean getBoolean(String parameterName) throws SQLException { return getOutputParameters().getBoolean(fixParameterName(parameterName)); } /** * @see java.sql.CallableStatement#setByte(java.lang.String, byte) */ public void setByte(String parameterName, byte x) throws SQLException { setByte(getNamedParamIndex(parameterName, false), x); } /** * @see java.sql.CallableStatement#getByte(int) */ public byte getByte(int parameterIndex) throws SQLException { return getOutputParameters().getByte(mapOutputParameterIndexToRsIndex( parameterIndex)); } /** * @see java.sql.CallableStatement#getByte(java.lang.String) */ public byte getByte(String parameterName) throws SQLException { return getOutputParameters().getByte(fixParameterName(parameterName)); } /** * @see java.sql.CallableStatement#setBytes(java.lang.String, byte[]) */ public void setBytes(String parameterName, byte[] x) throws SQLException { setBytes(getNamedParamIndex(parameterName, false), x); } /** * @see java.sql.CallableStatement#getBytes(java.lang.String) */ public byte[] getBytes(String parameterName) throws SQLException { return getOutputParameters().getBytes(fixParameterName(parameterName)); } /** * @see java.sql.CallableStatement#getBytes(int) */ public byte[] getBytes(int parameterIndex) throws SQLException { return getOutputParameters().getBytes(mapOutputParameterIndexToRsIndex( parameterIndex)); } /** * @see java.sql.CallableStatement#setCharacterStream(java.lang.String, * java.io.Reader, int) */ public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException { setCharacterStream(getNamedParamIndex(parameterName, false), reader, length); } /** * @see java.sql.CallableStatement#getClob(int) */ public Clob getClob(int parameterIndex) throws SQLException { return getOutputParameters().getClob(mapOutputParameterIndexToRsIndex( parameterIndex)); } /** * @see java.sql.CallableStatement#getClob(java.lang.String) */ public Clob getClob(String parameterName) throws SQLException { return getOutputParameters().getClob(fixParameterName(parameterName)); } /** * @see java.sql.CallableStatement#setDate(java.lang.String, java.sql.Date, * java.util.Calendar) */ public void setDate(String parameterName, Date x, Calendar cal) throws SQLException { setDate(getNamedParamIndex(parameterName, false), x, cal); } /** * @see java.sql.CallableStatement#setDate(java.lang.String, java.sql.Date) */ public void setDate(String parameterName, Date x) throws SQLException { setDate(getNamedParamIndex(parameterName, false), x); } /** * @see java.sql.CallableStatement#getDate(int, java.util.Calendar) */ public Date getDate(int parameterIndex, Calendar cal) throws SQLException { return getOutputParameters().getDate(mapOutputParameterIndexToRsIndex( parameterIndex), cal); } /** * @see java.sql.CallableStatement#getDate(int) */ public Date getDate(int parameterIndex) throws SQLException { return getOutputParameters().getDate(mapOutputParameterIndexToRsIndex( parameterIndex)); } /** * @see java.sql.CallableStatement#getDate(java.lang.String, * java.util.Calendar) */ public Date getDate(String parameterName, Calendar cal) throws SQLException { return getOutputParameters().getDate(fixParameterName(parameterName), cal); } /** * @see java.sql.CallableStatement#getDate(java.lang.String) */ public Date getDate(String parameterName) throws SQLException { return getOutputParameters().getDate(fixParameterName(parameterName)); } /** * @see java.sql.CallableStatement#setDouble(java.lang.String, double) */ public void setDouble(String parameterName, double x) throws SQLException { setDouble(getNamedParamIndex(parameterName, false), x); } /** * @see java.sql.CallableStatement#getDouble(int) */ public double getDouble(int parameterIndex) throws SQLException { return getOutputParameters().getDouble(mapOutputParameterIndexToRsIndex( parameterIndex)); } /** * @see java.sql.CallableStatement#getDouble(java.lang.String) */ public double getDouble(String parameterName) throws SQLException { return getOutputParameters().getDouble(fixParameterName(parameterName)); } /** * @see java.sql.CallableStatement#setFloat(java.lang.String, float) */ public void setFloat(String parameterName, float x) throws SQLException { setFloat(getNamedParamIndex(parameterName, false), x); } /** * @see java.sql.CallableStatement#getFloat(int) */ public float getFloat(int parameterIndex) throws SQLException { return getOutputParameters().getFloat(mapOutputParameterIndexToRsIndex( parameterIndex)); } /** * @see java.sql.CallableStatement#getFloat(java.lang.String) */ public float getFloat(String parameterName) throws SQLException { return getOutputParameters().getFloat(fixParameterName(parameterName)); } /** * @see java.sql.CallableStatement#setInt(java.lang.String, int) */ public void setInt(String parameterName, int x) throws SQLException { setInt(getNamedParamIndex(parameterName, false), x); } /** * @see java.sql.CallableStatement#getInt(int) */ public int getInt(int parameterIndex) throws SQLException { return getOutputParameters().getInt(mapOutputParameterIndexToRsIndex( parameterIndex)); } /** * @see java.sql.CallableStatement#getInt(java.lang.String) */ public int getInt(String parameterName) throws SQLException { return getOutputParameters().getInt(fixParameterName(parameterName)); } /** * @see java.sql.CallableStatement#setLong(java.lang.String, long) */ public void setLong(String parameterName, long x) throws SQLException { } /** * @see java.sql.CallableStatement#getLong(int) */ public long getLong(int parameterIndex) throws SQLException { return getOutputParameters().getLong(mapOutputParameterIndexToRsIndex( parameterIndex)); } /** * @see java.sql.CallableStatement#getLong(java.lang.String) */ public long getLong(String parameterName) throws SQLException { return getOutputParameters().getLong(fixParameterName(parameterName)); } /** * @see java.sql.CallableStatement#setNull(java.lang.String, int, * java.lang.String) */ public void setNull(String parameterName, int sqlType, String typeName) throws SQLException { }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -