/*
* Copyright 2008 biaoping.yin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.frameworkset.common.poolman;
import java.sql.Types;
import com.frameworkset.common.poolman.util.SQLUtil;
public class CallableParam extends Param
{
/**
* Registers the OUT parameter in ordinal position
* <code>parameterIndex</code> to the JDBC type
* <code>sqlType</code>. All OUT parameters must be registered
* before a stored procedure is executed.
* <p>
* The JDBC type specified by <code>sqlType</code> for an OUT
* parameter determines the Java type that must be used
* in the <code>get</code> method to read the value of that parameter.
* <p>
* If the JDBC type expected to be returned to this output parameter
* is specific to this particular database, <code>sqlType</code>
* should be <code>java.sql.Types.OTHER</code>. The method
* {@link #getObject} retrieves the value.
*
* @param parameterIndex the first parameter is 1, the second is 2,
* and so on
* @param sqlType the JDBC type code defined by <code>java.sql.Types</code>.
* If the parameter is of JDBC type <code>NUMERIC</code>
* or <code>DECIMAL</code>, the version of
* <code>registerOutParameter</code> that accepts a scale value
* should be used.
*
* @exception SQLException if a database access error occurs
* @see Types
*/
static final String registerOutParameter_int_parameterIndex_int_sqlType = "registerOutParameter(int parameterIndex, int sqlType)";
/**
* Registers the parameter in ordinal position
* <code>parameterIndex</code> to be of JDBC type
* <code>sqlType</code>. This method must be called
* before a stored procedure is executed.
* <p>
* The JDBC type specified by <code>sqlType</code> for an OUT
* parameter determines the Java type that must be used
* in the <code>get</code> method to read the value of that parameter.
* <p>
* This version of <code>registerOutParameter</code> should be
* used when the parameter is of JDBC type <code>NUMERIC</code>
* or <code>DECIMAL</code>.
*
* @param parameterIndex the first parameter is 1, the second is 2,
* and so on
* @param sqlType the SQL type code defined by <code>java.sql.Types</code>.
* @param scale the desired number of digits to the right of the
* decimal point. It must be greater than or equal to zero.
* @exception SQLException if a database access error occurs
* @see Types
*/
static final String registerOutParameter_int_parameterIndex_int_sqlType_int_scale = "registerOutParameter(int parameterIndex, int sqlType, int scale)";
/**
* Registers the designated output parameter. This version of
* the method <code>registerOutParameter</code>
* should be used for a user-defined or <code>REF</code> output parameter. Examples
* of user-defined types include: <code>STRUCT</code>, <code>DISTINCT</code>,
* <code>JAVA_OBJECT</code>, and named array types.
*
* Before executing a stored procedure call, you must explicitly
* call <code>registerOutParameter</code> to register the type from
* <code>java.sql.Types</code> for each
* OUT parameter. For a user-defined parameter, the fully-qualified SQL
* type name of the parameter should also be given, while a <code>REF</code>
* parameter requires that the fully-qualified type name of the
* referenced type be given. A JDBC driver that does not need the
* type code and type name information may ignore it. To be portable,
* however, applications should always provide these values for
* user-defined and <code>REF</code> parameters.
*
* Although it is intended for user-defined and <code>REF</code> parameters,
* this method may be used to register a parameter of any JDBC type.
* If the parameter does not have a user-defined or <code>REF</code> type, the
* <i>typeName</i> parameter is ignored.
*
* <P><B>Note:</B> When reading the value of an out parameter, you
* must use the getter method whose Java type corresponds to the
* parameter's registered SQL type.
*
* @param paramIndex the first parameter is 1, the second is 2,...
* @param sqlType a value from {@link java.sql.Types}
* @param typeName the fully-qualified name of an SQL structured type
* @exception SQLException if a database access error occurs
* @see Types
* @since 1.2
*/
static final String registerOutParameter_int_paramIndex_int_sqlType_String_typeName = "registerOutParameter (int paramIndex, int sqlType, String typeName)";
//--------------------------JDBC 3.0-----------------------------
/**
* Registers the OUT parameter named
* <code>parameterName</code> to the JDBC type
* <code>sqlType</code>. All OUT parameters must be registered
* before a stored procedure is executed.
* <p>
* The JDBC type specified by <code>sqlType</code> for an OUT
* parameter determines the Java type that must be used
* in the <code>get</code> method to read the value of that parameter.
* <p>
* If the JDBC type expected to be returned to this output parameter
* is specific to this particular database, <code>sqlType</code>
* should be <code>java.sql.Types.OTHER</code>. The method
* {@link #getObject} retrieves the value.
* @param parameterName the name of the parameter
* @param sqlType the JDBC type code defined by <code>java.sql.Types</code>.
* If the parameter is of JDBC type <code>NUMERIC</code>
* or <code>DECIMAL</code>, the version of
* <code>registerOutParameter</code> that accepts a scale value
* should be used.
* @exception SQLException if a database access error occurs
* @since 1.4
* @see Types
*/
static final String registerOutParameter_String_parameterName_int_sqlType = "registerOutParameter(String parameterName, int sqlType)";
/**
* Registers the parameter named
* <code>parameterName</code> to be of JDBC type
* <code>sqlType</code>. This method must be called
* before a stored procedure is executed.
* <p>
* The JDBC type specified by <code>sqlType</code> for an OUT
* parameter determines the Java type that must be used
* in the <code>get</code> method to read the value of that parameter.
* <p>
* This version of <code>registerOutParameter</code> should be
* used when the parameter is of JDBC type <code>NUMERIC</code>
* or <code>DECIMAL</code>.
* @param parameterName the name of the parameter
* @param sqlType SQL type code defined by <code>java.sql.Types</code>.
* @param scale the desired number of digits to the right of the
* decimal point. It must be greater than or equal to zero.
* @exception SQLException if a database access error occurs
* @since 1.4
* @see Types
*/
static final String registerOutParameter_String_parameterName_int_sqlType_int_scale = "registerOutParameter(String parameterName, int sqlType, int scale)";
/**
* Registers the designated output parameter. This version of
* the method <code>registerOutParameter</code>
* should be used for a user-named or REF output parameter. Examples
* of user-named types include: STRUCT, DISTINCT, JAVA_OBJECT, and
* named array types.
*
* Before executing a stored procedure call, you must explicitly
* call <code>registerOutParameter</code> to register the type from
* <code>java.sql.Types</code> for each
* OUT parameter. For a user-named parameter the fully-qualified SQL
* type name of the parameter should also be given, while a REF
* parameter requires that the fully-qualified type name of the
* referenced type be given. A JDBC driver that does not need the
* type code and type name information may ignore it. To be portable,
* however, applications should always provide these values for
* user-named and REF parameters.
*
* Although it is intended for user-named and REF parameters,
* this method may be used to register a parameter of any JDBC type.
* If the parameter does not have a user-named or REF type, the
* typeName parameter is ignored.
*
* <P><B>Note:</B> When reading the value of an out parameter, you
* must use the <code>getXXX</code> method whose Java type XXX corresponds to the
* parameter's registered SQL type.
*
* @param parameterName the name of the parameter
* @param sqlType a value from {@link java.sql.Types}
* @param typeName the fully-qualified name of an SQL structured type
* @exception SQLException if a database access error occurs
* @see Types
* @since 1.4
*/
static final String registerOutParameter_String_parameterName_int_sqlType_String_typeName = "registerOutParameter (String parameterName, int sqlType, String typeName)";
/**
* Sets the designated parameter to the given input stream, which will have
* the specified number of bytes.
* When a very large ASCII value is input to a <code>LONGVARCHAR</code>
* parameter, it may be more practical to send it via a
* <code>java.io.InputStream</code>. Data will be read from the stream
* as needed until end-of-file is reached. The JDBC driver will
* do any necessary conversion from ASCII to the database char format.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
*
* @param parameterName the name of the parameter
* @param x the Java input stream that contains the ASCII parameter value
* @param length the number of bytes in the stream
* @exception SQLException if a database access error occurs
* @since 1.4
*/
static final String setAsciiStream_String_parameterName_InputStream_x_int_length = "setAsciiStream(String parameterName, java.io.InputStream x, int length)";
/**
* Sets the designated parameter to the given
* <code>java.math.BigDecimal</code> value.
* The driver converts this to an SQL <code>NUMERIC</code> value when
* it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs
* @see #getBigDecimal
* @since 1.4
*/
static final String setBigDecimal_String_parameterName_BigDecimal_x = "setBigDecimal(String parameterName, BigDecimal x)";
/**
* Sets the designated parameter to the given input stream, which will have
* the specified number of bytes.
* When a very large binary value is input to a <code>LONGVARBINARY</code>
* parameter, it may be more practical to send it via a
* <code>java.io.InputStream</code> object. The data will be read from the stream
* as needed until end-of-file is reached.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
*
* @param parameterName the name of the parameter
* @param x the java input stream which contains the binary parameter value
* @param length the number of bytes in the stream
* @exception SQLException if a database access error occurs
* @since 1.4
*/
static final String setBinaryStream_String_parameterName_InputStream_x_int_length = "setBinaryStream(String parameterName, java.io.InputStream x, int length)";
/**
* Sets the designated parameter to the given Java <code>boolean</code> value.
* The driver converts this
* to an SQL <code>BIT</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs
* @see #getBoolean
* @since 1.4
*/
static final String setBoolean_String_parameterName_boolean_x = "setBoolean(String parameterName, boolean x)";
/**
* Sets the designated parameter to the given Java <code>byte</code> value.
* The driver converts this
* to an SQL <code>TINYINT</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs
* @see #getByte
* @since 1.4
*/
static final String setByte_String_parameterName_byte_x = "setByte(String parameterName, byte x)";
/**
* Sets the designated parameter to the given Java array of bytes.
* The driver converts this to an SQL <code>VARBINARY</code> or
* <code>LONGVARBINARY</code> (depending on the argument's size relative
* to the driver's limits on <code>VARBINARY</code> values) when it sends
* it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs
* @see #getBytes
* @since 1.4
*/
static final String setBytes_String_parameterName_byteArray_x = "setBytes(String parameterName, byte x[])";
/**
* Sets the designated parameter to the given <code>Reader</code>
* object, which is the given number of characters long.
* When a very large UNICODE value is input to a <code>LONGVARCHAR</code>
* parameter, it may be more practical to send it via a
* <code>java.io.Reader</code> object. The data will be read from the stream
* as needed until end-of-file is reached. The JDBC driver will
* do any necessary conversion from UNICODE to the database char format.
*
* <P><B>Note:</B> This stream object can either be a standard
* Java stream object or your own subclass that implements the
* standard interface.
*
* @param parameterName the name of the parameter
* @param reader the <code>java.io.Reader</code> object that
* contains the UNICODE data used as the designated parameter
* @param length the number of characters in the stream
* @exception SQLException if a database access error occurs
* @since 1.4
*/
static final String setCharacterStream_String_parameterName_Reader_reader_int_length = "setCharacterStream(String parameterName,java.io.Reader reader,int length)";
/**
* Sets the designated parameter to the given <code>java.sql.Date</code> value.
* The driver converts this
* to an SQL <code>DATE</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs
* @see #getDate
* @since 1.4
*/
static final String setDate_String_parameterName_Date_x = "setDate(String parameterName, java.sql.Date x)";
/**
* Sets the designated parameter to the given <code>java.sql.Date</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>DATE</code> value,
* which the driver then sends to the database. With a
* a <code>Calendar</code> object, the driver can calculate the date
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the date
* @exception SQLException if a database access error occurs
* @see #getDate
* @since 1.4
*/
static final String setDate_String_parameterName_Date_x_Calendar_cal = "setDate(String parameterName, java.sql.Date x, Calendar cal)";
/**
* Sets the designated parameter to the given Java <code>double</code> value.
* The driver converts this
* to an SQL <code>DOUBLE</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs
* @see #getDouble
* @since 1.4
*/
static final String setDouble_String_parameterName_double_x = "setDouble(String parameterName, double x)";
/**
* Sets the designated parameter to the given Java <code>float</code> value.
* The driver converts this
* to an SQL <code>FLOAT</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs
* @see #getFloat
* @since 1.4
*/
static final String setFloat_String_parameterName_float_x = "setFloat(String parameterName, float x)";
/**
* Sets the designated parameter to the given Java <code>int</code> value.
* The driver converts this
* to an SQL <code>INTEGER</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs
* @see #getInt
* @since 1.4
*/
static final String setInt_String_parameterName_int_x = "setInt(String parameterName, int x)";
/**
* Sets the designated parameter to the given Java <code>long</code> value.
* The driver converts this
* to an SQL <code>BIGINT</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs
* @see #getLong
* @since 1.4
*/
static final String setLong_String_parameterName_long_x = "setLong(String parameterName, long x)";
/**
* Sets the designated parameter to SQL <code>NULL</code>.
*
* <P><B>Note:</B> You must specify the parameter's SQL type.
*
* @param parameterName the name of the parameter
* @param sqlType the SQL type code defined in <code>java.sql.Types</code>
* @exception SQLException if a database access error occurs
* @since 1.4
*/
static final String setNull_String_parameterName_int_sqlType = "setNull(String parameterName, int sqlType)";
/**
* Sets the designated parameter to SQL <code>NULL</code>.
* This version of the method <code>setNull</code> should
* be used for user-defined types and REF type parameters. Examples
* of user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT, and
* named array types.
*
* <P><B>Note:</B> To be portable, applications must give the
* SQL type code and the fully-qualified SQL type name when specifying
* a NULL user-defined or REF parameter. In the case of a user-defined type
* the name is the type name of the parameter itself. For a REF
* parameter, the name is the type name of the referenced type. If
* a JDBC driver does not need the type code or type name information,
* it may ignore it.
*
* Although it is intended for user-defined and Ref parameters,
* this method may be used to set a null parameter of any JDBC type.
* If the parameter does not have a user-defined or REF type, the given
* typeName is ignored.
*
*
* @param parameterName the name of the parameter
* @param sqlType a value from <code>java.sql.Types</code>
* @param typeName the fully-qualified name of an SQL user-defined type;
* ignored if the parameter is not a user-defined type or
* SQL <code>REF</code> value
* @exception SQLException if a database access error occurs
* @since 1.4
*/
static final String setNull_String_parameterName_int_sqlType_String_typeName = "setNull(String parameterName, int sqlType, String typeName)";
/**
* Sets the value of the designated parameter with the given object.
* The second parameter must be of type <code>Object</code>; therefore, the
* <code>java.lang</code> equivalent objects should be used for built-in types.
*
* <p>The JDBC specification specifies a standard mapping from
* Java <code>Object</code> types to SQL types. The given argument
* will be converted to the corresponding SQL type before being
* sent to the database.
*
* <p>Note that this method may be used to pass datatabase-
* specific abstract data types, by using a driver-specific Java
* type.
*
* If the object is of a class implementing the interface <code>SQLData</code>,
* the JDBC driver should call the method <code>SQLData.writeSQL</code>
* to write it to the SQL data stream.
* If, on the other hand, the object is of a class implementing
* <code>Ref</code>, <code>Blob</code>, <code>Clob</code>, <code>Struct</code>,
* or <code>Array</code>, the driver should pass it to the database as a
* value of the corresponding SQL type.
* <P>
* This method throws an exception if there is an ambiguity, for example, if the
* object is of a class implementing more than one of the interfaces named above.
*
* @param parameterName the name of the parameter
* @param x the object containing the input parameter value
* @exception SQLException if a database access error occurs or if the given
* <code>Object</code> parameter is ambiguous
* @see #getObject
* @since 1.4
*/
static final String setObject_String_parameterName_Object_x = "setObject(String parameterName, Object x)";
/**
* Sets the value of the designated parameter with the given object.
* This method is like the method <code>setObject</code>
* above, except that it assumes a scale of zero.
*
* @param parameterName the name of the parameter
* @param x the object containing the input parameter value
* @param targetSqlType the SQL type (as defined in java.sql.Types) to be
* sent to the database
* @exception SQLException if a database access error occurs
* @see #getObject
* @since 1.4
*/
static final String setObject_String_parameterName_Object_x_int_targetSqlType = "setObject(String parameterName, Object x, int targetSqlType)";
/**
* Sets the value of the designated parameter with the given object. The second
* argument must be an object type; for integral values, the
* <code>java.lang</code> equivalent objects should be used.
*
* <p>The given Java object will be converted to the given targetSqlType
* before being sent to the database.
*
* If the object has a custom mapping (is of a class implementing the
* interface <code>SQLData</code>),
* the JDBC driver should call the method <code>SQLData.writeSQL</code> to write it
* to the SQL data stream.
* If, on the other hand, the object is of a class implementing
* <code>Ref</code>, <code>Blob</code>, <code>Clob</code>, <code>Struct</code>,
* or <code>Array</code>, the driver should pass it to the database as a
* value of the corresponding SQL type.
* <P>
* Note that this method may be used to pass datatabase-
* specific abstract data types.
*
* @param parameterName the name of the parameter
* @param x the object containing the input parameter value
* @param targetSqlType the SQL type (as defined in java.sql.Types) to be
* sent to the database. The scale argument may further qualify this type.
* @param scale for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types,
* this is the number of digits after the decimal point. For all other
* types, this value will be ignored.
* @exception SQLException if a database access error occurs
* @see Types
* @see #getObject
* @since 1.4
*/
static final String setObject_String_parameterName_Object_x_int_targetSqlType_int_scale = "setObject(String parameterName, Object x, int targetSqlType, int scale)";
/**
* Sets the designated parameter to the given Java <code>short</code> value.
* The driver converts this
* to an SQL <code>SMALLINT</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs
* @see #getShort
* @since 1.4
*/
static final String setShort_String_parameterName_short_x = "setShort(String parameterName, short x)";
/**
* Sets the designated parameter to the given Java <code>String</code> value.
* The driver converts this
* to an SQL <code>VARCHAR</code> or <code>LONGVARCHAR</code> value
* (depending on the argument's
* size relative to the driver's limits on <code>VARCHAR</code> values)
* when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs
* @see #getString
* @since 1.4
*/
static final String setString_String_parameterName_String_x = "setString(String parameterName, String x)";
/**
* Sets the designated parameter to the given <code>java.sql.Time</code> value.
* The driver converts this
* to an SQL <code>TIME</code> value when it sends it to the database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs
* @see #getTime
* @since 1.4
*/
static final String setTime_String_parameterName_Time_x = "setTime(String parameterName, java.sql.Time x)";
/**
* Sets the designated parameter to the given <code>java.sql.Time</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>TIME</code> value,
* which the driver then sends to the database. With a
* a <code>Calendar</code> object, the driver can calculate the time
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the time
* @exception SQLException if a database access error occurs
* @see #getTime
* @since 1.4
*/
static final String setTime_String_parameterName_Time_x_Calendar_cal = "setTime(String parameterName, java.sql.Time x, Calendar cal)";
/**
* Sets the designated parameter to the given <code>java.sql.Timestamp</code> value.
* The driver
* converts this to an SQL <code>TIMESTAMP</code> value when it sends it to the
* database.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @exception SQLException if a database access error occurs
* @see #getTimestamp
* @since 1.4
*/
static final String setTimestamp_String_parameterName_Timestamp_x = "setTimestamp(String parameterName, java.sql.Timestamp x)";
/**
* Sets the designated parameter to the given <code>java.sql.Timestamp</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>TIMESTAMP</code> value,
* which the driver then sends to the database. With a
* a <code>Calendar</code> object, the driver can calculate the timestamp
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
*
* @param parameterName the name of the parameter
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the timestamp
* @exception SQLException if a database access error occurs
* @see #getTimestamp
* @since 1.4
*/
static final String setTimestamp_String_parameterName_Timestamp_x_Calendar_cal = "setTimestamp(String parameterName, java.sql.Timestamp x, Calendar cal)";
/**
* Sets the designated parameter to the given <code>java.net.URL</code> object.
* The driver converts this to an SQL <code>DATALINK</code> value when
* it sends it to the database.
*
* @param parameterName the name of the parameter
* @param val the parameter value
* @exception SQLException if a database access error occurs,
* or if a URL is malformed
* @see #getURL
* @since 1.4
*/
static final String setURL_String_parameterName_URL_val = "setURL(String parameterName, java.net.URL val)";
String parameterName;
String typeName;
int sqlType;
int scale;
boolean isOut = false;
public String toString()
{
return new StringBuffer("method[")
.append(method)
.append("]index[")
.append(index)
.append("]value[")
.append(data)
.append("]parameterName[")
.append(parameterName)
.append("]sqlType[").append(SQLUtil.getSchemaType(null,sqlType,null))
.append("]scale[")
.append(scale)
.append("]isOut[")
.append(isOut)
.append("]")
.toString();
}
public String toString(String dbName)
{
return new StringBuffer("method[")
.append(method)
.append("]index[")
.append(index)
.append("]value[")
.append(data)
.append("]parameterName[")
.append(parameterName)
.append("]sqlType[").append(SQLUtil.getSchemaType(dbName,sqlType,null))
.append("]scale[")
.append(scale)
.append("]isOut[")
.append(isOut)
.append("]")
.toString();
}
}