Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |
CallableStatement is used to execute SQL stored procedures.
JDBC provides a stored procedure SQL escape that allows stored procedures to be called in a standard way for all RDBMS's. This escape syntax has one form that includes a result parameter and one that does not. If used, the result parameter must be registered as an OUT parameter. The other parameters may be used for input, output or both. Parameters are refered to sequentially, by number. The first parameter is 1.
{?= call <procedure-name>[<arg1>,<arg2>, ...]} {call <procedure-name>[<arg1>,<arg2>, ...]}
IN parameter values are set using the set methods inherited from PreparedStatement. The type of all OUT parameters must be registered prior to executing the stored procedure; their values are retrieved after execution via the get methods provided here.
A Callable statement may return a ResultSet or multiple ResultSets. Multiple ResultSets are handled using operations inherited from Statement.
For maximum portability, a call's ResultSets and update counts should be processed prior to getting the values of output parameters.
Method Summary | |
ArrayLocator | getArrayLocator(int i)
|
BigDecimal | getBigDecimal(int parameterIndex,
int scale)
|
BigDecimal | getBigDecimal(int parameterIndex)
|
BlobLocator | GetBlobLocator(int i)
|
boolean | getBoolean(int parameterIndex)
|
byte | getByte(int parameterIndex)
|
byte[] | getBytes(int parameterIndex)
|
ClobLocator | getClobLocator(int i)
|
Date | getDate(int parameterIndex)
|
double | getDouble(int parameterIndex)
|
float | getFloat(int parameterIndex)
|
int | getInt(int parameterIndex)
|
long | getLong(int parameterIndex)
|
Object | getObject(int parameterIndex)
|
Object | getObject(int i,
Map map)
|
Ref | getRef(int i)
|
short | getShort(int parameterIndex)
|
String | getString(int parameterIndex)
|
StructLocator | getStructLocator(int i)
|
Time | getTime(int parameterIndex)
|
Timestamp | getTimestamp(int parameterIndex)
|
void | registerOutParameter(int parameterIndex,
int sqlType)
|
void | registerOutParameter(int parameterIndex,
int sqlType,
int scale)
|
boolean | wasNull()
|
Method Detail |
public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException
Note: When reading the value of an out parameter, you must use the getXXX method whose Java type XXX corresponds to the parameter's registered SQL type.
parameterIndex
- the first parameter is 1, the second is 2,...
sqlType
- SQL type code defined by java.sql.Types;
for parameters of type Numeric or Decimal use the version of
registerOutParameter that accepts a scale value
public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException
Note: When reading the value of an out parameter, you must use the getXXX method whose Java type XXX corresponds to the parameter's registered SQL type.
parameterIndex
- the first parameter is 1, the second is 2, ...
sqlType
- use either java.sql.Type.NUMERIC or java.sql.Type.DECIMAL
scale
- a value greater than or equal to zero representing the
desired number of digits to the right of the decimal point
public boolean wasNull() throws SQLException
Note: You must first call getXXX on a parameter to read its value and then call wasNull() to see if the value was SQL NULL.
public String getString(int parameterIndex) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
public boolean getBoolean(int parameterIndex) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
public byte getByte(int parameterIndex) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
public short getShort(int parameterIndex) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
public int getInt(int parameterIndex) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
public long getLong(int parameterIndex) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
public float getFloat(int parameterIndex) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
public double getDouble(int parameterIndex) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
scale
- a value greater than or equal to zero representing the
desired number of digits to the right of the decimal point
public byte[] getBytes(int parameterIndex) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
public Date getDate(int parameterIndex) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
public Time getTime(int parameterIndex) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
public Timestamp getTimestamp(int parameterIndex) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
public Object getObject(int parameterIndex) throws SQLException
This method returns a Java object whose type coresponds to the SQL type that was registered for this parameter using registerOutParameter.
Note that this method may be used to read datatabase-specific, abstract data types. This is done by specifying a targetSqlType of java.sql.types.OTHER, which allows the driver to return a database-specific Java type.
parameterIndex
- The first parameter is 1, the second is 2, ...
public BigDecimal getBigDecimal(int parameterIndex) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...
public Object getObject(int i, Map map) throws SQLException
i
- the first parameter is 1, the second is 2, ...
map
- the mapping from SQL type names to Java classes
public Ref getRef(int i) throws SQLException
i
- the first parameter is 1, the second is 2, ...
public BlobLocator GetBlobLocator(int i) throws SQLException
i
- the first parameter is 1, the second is 2, ...
public ClobLocator getClobLocator(int i) throws SQLException
i
- the first parameter is 1, the second is 2, ...
public StructLocator getStructLocator(int i) throws SQLException
i
- the first parameter is 1, the second is 2, ...
public ArrayLocator getArrayLocator(int i) throws SQLException
i
- the first parameter is 1, the second is 2, ...
Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |