Package net.sourceforge.jtds.jdbc
Class JtdsCallableStatement
java.lang.Object
net.sourceforge.jtds.jdbc.JtdsStatement
net.sourceforge.jtds.jdbc.JtdsPreparedStatement
net.sourceforge.jtds.jdbc.JtdsCallableStatement
- All Implemented Interfaces:
AutoCloseable
,CallableStatement
,PreparedStatement
,Statement
,Wrapper
jTDS implementation of the java.sql.CallableStatement interface.
Implementation note:
- This class is a simple subclass of PreparedStatement and mainly adds support for setting parameters.
- The class supports named parameters in a similar way to the patch supplied by Tommy Sandstrom to the original jTDS code.
- Version:
- $Id: JtdsCallableStatement.java,v 1.23.2.4 2009-12-30 11:37:21 ickzon Exp $
- Author:
- Mike Hutchinson
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Last parameter retrieved was null.Fields inherited from class net.sourceforge.jtds.jdbc.JtdsPreparedStatement
handles, parameters, paramMetaData, procName, sql, sqlWord
Fields inherited from class net.sourceforge.jtds.jdbc.JtdsStatement
batchValues, BOOLEAN, CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, colMetaData, connection, currentResult, cursorName, DATALINK, DEFAULT_FETCH_SIZE, escapeProcessing, EXECUTE_FAILED, fetchDirection, fetchSize, GENKEYCOL, genKeyResultSet, KEEP_CURRENT_RESULT, maxFieldSize, maxRows, messages, NO_GENERATED_KEYS, openResultSets, queryTimeout, resultQueue, resultSetConcurrency, resultSetType, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO, tds
Fields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
-
Constructor Summary
ConstructorsConstructorDescriptionJtdsCallableStatement
(JtdsConnection connection, String sql, int resultSetType, int concurrency) Construct a CallableStatement object. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Check that this statement is still open.void
protected SQLException
executeMSBatch
(int size, int executeSize, ArrayList counts) Execute the SQL batch on a MS server.protected SQLException
executeSybaseBatch
(int size, int executeSize, ArrayList counts) Execute the SQL batch on a Sybase server.(package private) final int
findParameter
(String name, boolean set) Find a parameter by name.getArray
(int parameterIndex) getBigDecimal
(int parameterIndex) getBigDecimal
(int parameterIndex, int scale) getBigDecimal
(String parameterName) getBlob
(int parameterIndex) boolean
getBoolean
(int parameterIndex) boolean
getBoolean
(String parameterName) byte
getByte
(int parameterIndex) byte
byte[]
getBytes
(int parameterIndex) byte[]
getCharacterStream
(int parameterIndex) getCharacterStream
(String parameterName) getClob
(int parameterIndex) getDate
(int parameterIndex) double
getDouble
(int parameterIndex) double
float
getFloat
(int parameterIndex) float
int
getInt
(int parameterIndex) int
long
getLong
(int parameterIndex) long
getNCharacterStream
(int parameterIndex) getNCharacterStream
(String parameterName) getNClob
(int parameterIndex) getNString
(int parameterIndex) getNString
(String parameterName) getObject
(int parameterIndex) <T> T
<T> T
protected Object
getOutputValue
(int parameterIndex) Retrieve the value of an output parameter.getRef
(int parameterIndex) getRowId
(int parameterIndex) short
getShort
(int parameterIndex) short
getSQLXML
(int parameterIndex) getString
(int parameterIndex) getTime
(int parameterIndex) getTimestamp
(int parameterIndex) getTimestamp
(int parameterIndex, Calendar cal) getTimestamp
(String parameterName) getTimestamp
(String parameterName, Calendar cal) getURL
(int parameterIndex) boolean
void
registerOutParameter
(int parameterIndex, int sqlType) void
registerOutParameter
(int parameterIndex, int sqlType, int scale) void
registerOutParameter
(int parameterIndex, int sqlType, String typeName) void
registerOutParameter
(String parameterName, int sqlType) void
registerOutParameter
(String parameterName, int sqlType, int scale) void
registerOutParameter
(String parameterName, int sqlType, String typeName) void
setAsciiStream
(String parameterName, InputStream x) void
setAsciiStream
(String parameterName, InputStream x, int length) void
setAsciiStream
(String parameterName, InputStream x, long length) void
setBigDecimal
(String parameterName, BigDecimal x) void
setBinaryStream
(String parameterName, InputStream x) void
setBinaryStream
(String parameterName, InputStream x, int length) void
setBinaryStream
(String parameterName, InputStream x, long length) void
setBlob
(String parameterName, InputStream inputStream) void
setBlob
(String parameterName, InputStream inputStream, long length) void
void
setBoolean
(String parameterName, boolean x) void
void
void
setCharacterStream
(String parameterName, Reader reader) void
setCharacterStream
(String parameterName, Reader reader, int length) void
setCharacterStream
(String parameterName, Reader reader, long length) void
void
void
void
void
void
void
void
void
void
setNCharacterStream
(String parameterName, Reader value) void
setNCharacterStream
(String parameterName, Reader value, long length) void
void
void
void
setNString
(String parameterName, String value) void
void
void
void
void
void
void
void
void
void
void
void
setTimestamp
(String parameterName, Timestamp x) void
setTimestamp
(String parameterName, Timestamp x, Calendar cal) void
boolean
wasNull()
Methods inherited from class net.sourceforge.jtds.jdbc.JtdsPreparedStatement
addBatch, addBatch, clearParameters, close, execute, execute, execute, execute, execute, executeQuery, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getMetaData, getParameter, getParameterMetaData, normalizeCall, notSupported, setArray, setAsciiStream, setAsciiStream, setAsciiStream, setBigDecimal, setBinaryStream, setBinaryStream, setBinaryStream, setBlob, setBlob, setBlob, setBoolean, setByte, setBytes, setCharacterStream, setCharacterStream, setCharacterStream, setClob, setClob, setClob, setColMetaData, setDate, setDate, setDouble, setFloat, setInt, setLong, setNCharacterStream, setNCharacterStream, setNClob, setNClob, setNClob, setNString, setNull, setNull, setObject, setObject, setObject, setObjectBase, setParameter, setParamMetaData, setRef, setRowId, setShort, setSQLXML, setString, setTime, setTime, setTimestamp, setTimestamp, setUnicodeStream, setURL, toString
Methods inherited from class net.sourceforge.jtds.jdbc.JtdsStatement
addWarning, cacheResults, cancel, checkCursorException, clearBatch, clearWarnings, closeAllResultSets, closeCurrentResultSet, executeBatch, executeSQL, executeSQLQuery, finalize, getConnection, getDefaultFetchSize, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMessages, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getTds, getUpdateCount, getWarnings, isClosed, isPoolable, isWrapperFor, notImplemented, reset, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout, unwrap, useCursor
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.sql.CallableStatement
registerOutParameter, registerOutParameter, registerOutParameter, registerOutParameter, registerOutParameter, registerOutParameter, setObject, setObject
Methods inherited from interface java.sql.PreparedStatement
addBatch, clearParameters, execute, executeLargeUpdate, executeQuery, executeUpdate, getMetaData, getParameterMetaData, setArray, setAsciiStream, setAsciiStream, setAsciiStream, setBigDecimal, setBinaryStream, setBinaryStream, setBinaryStream, setBlob, setBlob, setBlob, setBoolean, setByte, setBytes, setCharacterStream, setCharacterStream, setCharacterStream, setClob, setClob, setClob, setDate, setDate, setDouble, setFloat, setInt, setLong, setNCharacterStream, setNCharacterStream, setNClob, setNClob, setNClob, setNString, setNull, setNull, setObject, setObject, setObject, setObject, setObject, setRef, setRowId, setShort, setSQLXML, setString, setTime, setTime, setTimestamp, setTimestamp, setUnicodeStream, setURL
Methods inherited from interface java.sql.Statement
addBatch, cancel, clearBatch, clearWarnings, close, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, execute, execute, execute, execute, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isPoolable, isSimpleIdentifier, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
Field Details
-
paramWasNull
protected boolean paramWasNullLast parameter retrieved was null.
-
-
Constructor Details
-
JtdsCallableStatement
JtdsCallableStatement(JtdsConnection connection, String sql, int resultSetType, int concurrency) throws SQLException Construct a CallableStatement object.- Parameters:
connection
- The connection owning this statement.sql
- The SQL statement specifying the procedure to call.resultSetType
- The result set type eg FORWARD_ONLY.concurrency
- The result set concurrency eg READ_ONLY.- Throws:
SQLException
-
-
Method Details
-
findParameter
Find a parameter by name.- Parameters:
name
- The name of the parameter to locate.set
- True if function is called from a set / register method.- Returns:
- The parameter index as an
int
. - Throws:
SQLException
-
getOutputValue
Retrieve the value of an output parameter.- Parameters:
parameterIndex
- the ordinal position of the parameter- Returns:
- the parameter value as an
Object
- Throws:
SQLException
- if the parameter has not been set
-
checkOpen
Check that this statement is still open.- Overrides:
checkOpen
in classJtdsPreparedStatement
- Throws:
SQLException
- if statement closed.
-
executeMSBatch
protected SQLException executeMSBatch(int size, int executeSize, ArrayList counts) throws SQLException Execute the SQL batch on a MS server.- Overrides:
executeMSBatch
in classJtdsPreparedStatement
- Parameters:
size
- the total size of the batch.executeSize
- the maximum number of statements to send in one request.counts
- the returned update counts.- Returns:
- Chained exceptions linked to a
SQLException
. - Throws:
SQLException
-
executeSybaseBatch
protected SQLException executeSybaseBatch(int size, int executeSize, ArrayList counts) throws SQLException Execute the SQL batch on a Sybase server. For the rare case of CallableStatement batches each statement is executed individually. This ensures that problems with the server reading into the middle of a statement are avoided. See bug report [1374518] for more details.- Overrides:
executeSybaseBatch
in classJtdsPreparedStatement
- Parameters:
size
- the total size of the batchexecuteSize
- the maximum number of statements to send in one request (ignored for this version of the method as only one statement will be sent at a time)counts
- the returned update counts- Returns:
- chained exceptions linked to a
SQLException
- Throws:
SQLException
- if a serious error occurs during execution
-
wasNull
- Specified by:
wasNull
in interfaceCallableStatement
- Throws:
SQLException
-
getByte
- Specified by:
getByte
in interfaceCallableStatement
- Throws:
SQLException
-
getDouble
- Specified by:
getDouble
in interfaceCallableStatement
- Throws:
SQLException
-
getFloat
- Specified by:
getFloat
in interfaceCallableStatement
- Throws:
SQLException
-
getInt
- Specified by:
getInt
in interfaceCallableStatement
- Throws:
SQLException
-
getLong
- Specified by:
getLong
in interfaceCallableStatement
- Throws:
SQLException
-
getShort
- Specified by:
getShort
in interfaceCallableStatement
- Throws:
SQLException
-
getBoolean
- Specified by:
getBoolean
in interfaceCallableStatement
- Throws:
SQLException
-
getBytes
- Specified by:
getBytes
in interfaceCallableStatement
- Throws:
SQLException
-
registerOutParameter
- Specified by:
registerOutParameter
in interfaceCallableStatement
- Throws:
SQLException
-
registerOutParameter
- Specified by:
registerOutParameter
in interfaceCallableStatement
- Throws:
SQLException
-
getObject
- Specified by:
getObject
in interfaceCallableStatement
- Throws:
SQLException
-
getString
- Specified by:
getString
in interfaceCallableStatement
- Throws:
SQLException
-
registerOutParameter
public void registerOutParameter(int parameterIndex, int sqlType, String typeName) throws SQLException - Specified by:
registerOutParameter
in interfaceCallableStatement
- Throws:
SQLException
-
getByte
- Specified by:
getByte
in interfaceCallableStatement
- Throws:
SQLException
-
getDouble
- Specified by:
getDouble
in interfaceCallableStatement
- Throws:
SQLException
-
getFloat
- Specified by:
getFloat
in interfaceCallableStatement
- Throws:
SQLException
-
getInt
- Specified by:
getInt
in interfaceCallableStatement
- Throws:
SQLException
-
getLong
- Specified by:
getLong
in interfaceCallableStatement
- Throws:
SQLException
-
getShort
- Specified by:
getShort
in interfaceCallableStatement
- Throws:
SQLException
-
getBoolean
- Specified by:
getBoolean
in interfaceCallableStatement
- Throws:
SQLException
-
getBytes
- Specified by:
getBytes
in interfaceCallableStatement
- Throws:
SQLException
-
setByte
- Specified by:
setByte
in interfaceCallableStatement
- Throws:
SQLException
-
setDouble
- Specified by:
setDouble
in interfaceCallableStatement
- Throws:
SQLException
-
setFloat
- Specified by:
setFloat
in interfaceCallableStatement
- Throws:
SQLException
-
registerOutParameter
- Specified by:
registerOutParameter
in interfaceCallableStatement
- Throws:
SQLException
-
setInt
- Specified by:
setInt
in interfaceCallableStatement
- Throws:
SQLException
-
setNull
- Specified by:
setNull
in interfaceCallableStatement
- Throws:
SQLException
-
registerOutParameter
- Specified by:
registerOutParameter
in interfaceCallableStatement
- Throws:
SQLException
-
setLong
- Specified by:
setLong
in interfaceCallableStatement
- Throws:
SQLException
-
setShort
- Specified by:
setShort
in interfaceCallableStatement
- Throws:
SQLException
-
setBoolean
- Specified by:
setBoolean
in interfaceCallableStatement
- Throws:
SQLException
-
setBytes
- Specified by:
setBytes
in interfaceCallableStatement
- Throws:
SQLException
-
getBigDecimal
- Specified by:
getBigDecimal
in interfaceCallableStatement
- Throws:
SQLException
-
getBigDecimal
- Specified by:
getBigDecimal
in interfaceCallableStatement
- Throws:
SQLException
-
getURL
- Specified by:
getURL
in interfaceCallableStatement
- Throws:
SQLException
-
getArray
- Specified by:
getArray
in interfaceCallableStatement
- Throws:
SQLException
-
getBlob
- Specified by:
getBlob
in interfaceCallableStatement
- Throws:
SQLException
-
getClob
- Specified by:
getClob
in interfaceCallableStatement
- Throws:
SQLException
-
getDate
- Specified by:
getDate
in interfaceCallableStatement
- Throws:
SQLException
-
getRef
- Specified by:
getRef
in interfaceCallableStatement
- Throws:
SQLException
-
getTime
- Specified by:
getTime
in interfaceCallableStatement
- Throws:
SQLException
-
getTimestamp
- Specified by:
getTimestamp
in interfaceCallableStatement
- Throws:
SQLException
-
setAsciiStream
- Specified by:
setAsciiStream
in interfaceCallableStatement
- Throws:
SQLException
-
setBinaryStream
- Specified by:
setBinaryStream
in interfaceCallableStatement
- Throws:
SQLException
-
setCharacterStream
- Specified by:
setCharacterStream
in interfaceCallableStatement
- Throws:
SQLException
-
getObject
- Specified by:
getObject
in interfaceCallableStatement
- Throws:
SQLException
-
setObject
- Specified by:
setObject
in interfaceCallableStatement
- Throws:
SQLException
-
setObject
- Specified by:
setObject
in interfaceCallableStatement
- Throws:
SQLException
-
setObject
public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException - Specified by:
setObject
in interfaceCallableStatement
- Throws:
SQLException
-
getObject
- Specified by:
getObject
in interfaceCallableStatement
- Throws:
SQLException
-
getString
- Specified by:
getString
in interfaceCallableStatement
- Throws:
SQLException
-
registerOutParameter
public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException - Specified by:
registerOutParameter
in interfaceCallableStatement
- Throws:
SQLException
-
setNull
- Specified by:
setNull
in interfaceCallableStatement
- Throws:
SQLException
-
setString
- Specified by:
setString
in interfaceCallableStatement
- Throws:
SQLException
-
getBigDecimal
- Specified by:
getBigDecimal
in interfaceCallableStatement
- Throws:
SQLException
-
setBigDecimal
- Specified by:
setBigDecimal
in interfaceCallableStatement
- Throws:
SQLException
-
getURL
- Specified by:
getURL
in interfaceCallableStatement
- Throws:
SQLException
-
setURL
- Specified by:
setURL
in interfaceCallableStatement
- Throws:
SQLException
-
getArray
- Specified by:
getArray
in interfaceCallableStatement
- Throws:
SQLException
-
getBlob
- Specified by:
getBlob
in interfaceCallableStatement
- Throws:
SQLException
-
getClob
- Specified by:
getClob
in interfaceCallableStatement
- Throws:
SQLException
-
getDate
- Specified by:
getDate
in interfaceCallableStatement
- Throws:
SQLException
-
setDate
- Specified by:
setDate
in interfaceCallableStatement
- Throws:
SQLException
-
getDate
- Specified by:
getDate
in interfaceCallableStatement
- Throws:
SQLException
-
getRef
- Specified by:
getRef
in interfaceCallableStatement
- Throws:
SQLException
-
getTime
- Specified by:
getTime
in interfaceCallableStatement
- Throws:
SQLException
-
setTime
- Specified by:
setTime
in interfaceCallableStatement
- Throws:
SQLException
-
getTime
- Specified by:
getTime
in interfaceCallableStatement
- Throws:
SQLException
-
getTimestamp
- Specified by:
getTimestamp
in interfaceCallableStatement
- Throws:
SQLException
-
setTimestamp
- Specified by:
setTimestamp
in interfaceCallableStatement
- Throws:
SQLException
-
getTimestamp
- Specified by:
getTimestamp
in interfaceCallableStatement
- Throws:
SQLException
-
getObject
- Specified by:
getObject
in interfaceCallableStatement
- Throws:
SQLException
-
getDate
- Specified by:
getDate
in interfaceCallableStatement
- Throws:
SQLException
-
getTime
- Specified by:
getTime
in interfaceCallableStatement
- Throws:
SQLException
-
getTimestamp
- Specified by:
getTimestamp
in interfaceCallableStatement
- Throws:
SQLException
-
setDate
- Specified by:
setDate
in interfaceCallableStatement
- Throws:
SQLException
-
setTime
- Specified by:
setTime
in interfaceCallableStatement
- Throws:
SQLException
-
setTimestamp
- Specified by:
setTimestamp
in interfaceCallableStatement
- Throws:
SQLException
-
getCharacterStream
- Specified by:
getCharacterStream
in interfaceCallableStatement
- Throws:
SQLException
-
getCharacterStream
- Specified by:
getCharacterStream
in interfaceCallableStatement
- Throws:
SQLException
-
getNCharacterStream
- Specified by:
getNCharacterStream
in interfaceCallableStatement
- Throws:
SQLException
-
getNCharacterStream
- Specified by:
getNCharacterStream
in interfaceCallableStatement
- Throws:
SQLException
-
getNClob
- Specified by:
getNClob
in interfaceCallableStatement
- Throws:
SQLException
-
getNClob
- Specified by:
getNClob
in interfaceCallableStatement
- Throws:
SQLException
-
getNString
- Specified by:
getNString
in interfaceCallableStatement
- Throws:
SQLException
-
getNString
- Specified by:
getNString
in interfaceCallableStatement
- Throws:
SQLException
-
getRowId
- Specified by:
getRowId
in interfaceCallableStatement
- Throws:
SQLException
-
getRowId
- Specified by:
getRowId
in interfaceCallableStatement
- Throws:
SQLException
-
getSQLXML
- Specified by:
getSQLXML
in interfaceCallableStatement
- Throws:
SQLException
-
getSQLXML
- Specified by:
getSQLXML
in interfaceCallableStatement
- Throws:
SQLException
-
setAsciiStream
- Specified by:
setAsciiStream
in interfaceCallableStatement
- Throws:
SQLException
-
setAsciiStream
- Specified by:
setAsciiStream
in interfaceCallableStatement
- Throws:
SQLException
-
setBinaryStream
- Specified by:
setBinaryStream
in interfaceCallableStatement
- Throws:
SQLException
-
setBinaryStream
- Specified by:
setBinaryStream
in interfaceCallableStatement
- Throws:
SQLException
-
setBlob
- Specified by:
setBlob
in interfaceCallableStatement
- Throws:
SQLException
-
setBlob
- Specified by:
setBlob
in interfaceCallableStatement
- Throws:
SQLException
-
setBlob
- Specified by:
setBlob
in interfaceCallableStatement
- Throws:
SQLException
-
setCharacterStream
- Specified by:
setCharacterStream
in interfaceCallableStatement
- Throws:
SQLException
-
setCharacterStream
public void setCharacterStream(String parameterName, Reader reader, long length) throws SQLException - Specified by:
setCharacterStream
in interfaceCallableStatement
- Throws:
SQLException
-
setClob
- Specified by:
setClob
in interfaceCallableStatement
- Throws:
SQLException
-
setClob
- Specified by:
setClob
in interfaceCallableStatement
- Throws:
SQLException
-
setClob
- Specified by:
setClob
in interfaceCallableStatement
- Throws:
SQLException
-
setNCharacterStream
- Specified by:
setNCharacterStream
in interfaceCallableStatement
- Throws:
SQLException
-
setNCharacterStream
public void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException - Specified by:
setNCharacterStream
in interfaceCallableStatement
- Throws:
SQLException
-
setNClob
- Specified by:
setNClob
in interfaceCallableStatement
- Throws:
SQLException
-
setNClob
- Specified by:
setNClob
in interfaceCallableStatement
- Throws:
SQLException
-
setNClob
- Specified by:
setNClob
in interfaceCallableStatement
- Throws:
SQLException
-
setNString
- Specified by:
setNString
in interfaceCallableStatement
- Throws:
SQLException
-
setRowId
- Specified by:
setRowId
in interfaceCallableStatement
- Throws:
SQLException
-
setSQLXML
- Specified by:
setSQLXML
in interfaceCallableStatement
- Throws:
SQLException
-
closeOnCompletion
- Specified by:
closeOnCompletion
in interfaceStatement
- Overrides:
closeOnCompletion
in classJtdsStatement
- Throws:
SQLException
-
isCloseOnCompletion
- Specified by:
isCloseOnCompletion
in interfaceStatement
- Overrides:
isCloseOnCompletion
in classJtdsStatement
- Throws:
SQLException
-
getObject
- Specified by:
getObject
in interfaceCallableStatement
- Throws:
SQLException
-
getObject
- Specified by:
getObject
in interfaceCallableStatement
- Throws:
SQLException
-