com.northgateis.reality.realsql
Class RealSQLPreparedStatement

java.lang.Object
 |
 +--com.northgateis.reality.realsql.RealSQLStatement
        |
 +--com.northgateis.reality.realsql.RealSQLPreparedStatement
Direct Known Subclasses:
RealSQLCallableStatement

public class RealSQLPreparedStatement
extends RealSQLStatement
implements java.sql.PreparedStatement

The RealSQLPreparedStatement class is an implementation of the JDBC 2.0 PreparedStatement interface.

When instantiated the object represents a precompiled SQL statement, and can be used to efficiently execute this statement multiple times.

See Also:
PreparedStatement, Connection.prepareStatement(java.lang.String), ResultSet

Method Summary
 void addBatch()
          Currently not supported by the RealSQL-JDBC driver.
 void clearParameters()
          Clears the current input parameters.
 void close()
          Closes the statement and any associated ResultSet.
 boolean execute()
          Executes the stored procedure with its current values.
 java.sql.ResultSet executeQuery()
          Executes the stored query with its current values.
 int executeUpdate()
          Executes the stored update with its current values.
protected  RealParamData getInputParam(int index)
          Retrieves the input parameter specified by the index.
 java.sql.ResultSetMetaData getMetaData()
          JDBC 2.0 Gets the number, types and properties of a ResultSet's columns.
protected  int getParamCount()
          Retrieves the total number of parameters used by this stored procedure.
protected  void sendParams()
          Forwards the values of all registered INPUT parameters to the Reality server, this must be called prior to executing the stored procedure.
 void setArray(int index, java.sql.Array sqlarray)
          Currently not supported by the RealSQL-JDBC driver.
 void setAsciiStream(int index, java.io.InputStream is, int len)
          Sets the parameter to the data in the specified stream.
 void setBigDecimal(int index, java.math.BigDecimal bd)
          Sets the specified parameter to a BigDecimal value.
 void setBinaryStream(int index, java.io.InputStream is, int len)
          Currently not supported by the RealSQL-JDBC driver.
 void setBlob(int index, java.sql.Blob b)
          Currently not supported by the RealSQL-JDBC driver.
 void setBoolean(int index, boolean b)
          Currently not supported by the RealSQL-JDBC driver.
 void setByte(int index, byte b)
          Sets the specified parameter to the specified byte value.
 void setBytes(int index, byte[] barray)
          Sets the specified parameter to the specified byte value.
 void setCharacterStream(int index, java.io.Reader in, int len)
          Currently not supported by the RealSQL-JDBC driver.
 void setClob(int index, java.sql.Clob c)
          Currently not supported by the RealSQL-JDBC driver.
 void setDate(int index, java.sql.Date d)
          Sets the designated parameter to a java.sql.Date value.
 void setDate(int index, java.sql.Date d, java.util.Calendar cal)
          JDBC 2.0 Sets the designated parameter to a java.sql.Date value, using the given Calendar object.
 void setDouble(int index, double d)
          Sets the specified parameter to a double value.
 void setFloat(int index, float f)
          Sets the specified parameter to a float value.
 void setInt(int index, int i)
          Sets the specified parameter to an int value.
 void setLong(int index, long l)
          Sets the specified parameter to a long value.
 void setNull(int index, int type)
          Sets the specified parameter to a null value.
 void setNull(int index, int type, java.lang.String tname)
          JDBC 2.0 Sets the specified parameter to a null value.
 void setObject(int index, java.lang.Object obj)
          Sets the specified parameter to a Java object value using the standard mapping from Java Object types to SQL types.
 void setObject(int index, java.lang.Object obj, int targetSqlType)
          Sets the specified parameter to a Java object value according to the SQL type specified.
 void setObject(int index, java.lang.Object obj, int targetSqlType, int scale)
          Sets the specified parameter to a Java object value according to the SQL type specified.
 void setRef(int index, java.sql.Ref r)
          Currently not supported by the RealSQL-JDBC driver.
 void setShort(int index, short s)
          Sets the specified parameter to a short value.
 void setString(int index, java.lang.String str)
          Sets the specified parameter to a String value.
 void setTime(int index, java.sql.Time t)
          Sets the specified parameter to a Time value.
 void setTime(int index, java.sql.Time t, java.util.Calendar cal)
          Sets the specified parameter to a Time value.
 void setTimestamp(int index, java.sql.Timestamp t)
          Sets the specified parameter to a Timestamp value.
 void setTimestamp(int index, java.sql.Timestamp t, java.util.Calendar cal)
          Sets the specified parameter to a Timestamp value.
 void setUnicodeStream(int index, java.io.InputStream is, int len)
          Deprecated. use setCharacterStream()
protected  void validateIndex(int index)
          Verifies that the specified index is valid for this stored procedure.
 
Methods inherited from class com.northgateis.reality.realsql.RealSQLStatement
addBatch, addResultSet, cancel, clearBatch, clearWarnings, completeLoad, execute, executeBatch, executeCatalogQuery, executeCommon, executeQuery, executeQueryCommon, executeStmt, executeUpdate, executeUpdateCommon, getConnection, getFetchDirection, getFetchSize, getMaxFieldSize, getMaxRows, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetType, getUpdateCount, getWarnings, isCatalogQuery, methodNotSupported, prepareStmt, reset, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addBatch

public void addBatch()
 throws java.sql.SQLException
Currently not supported by the RealSQL-JDBC driver.

Adds the current parameter values to the batch list and then clears the parameters for the next set of parameters.

Specified by:
addBatch in interface java.sql.PreparedStatement
Throws:
java.sql.SQLException - IM001 - "Driver does not support this function".


clearParameters

public void clearParameters()
 throws java.sql.SQLException
Clears the current input parameters. This does not clear any input parameters previously sent to the server, you must use the appropriate setXXX method to ensure new values are sent to the server prior to executing the statement.
Specified by:
clearParameters in interface java.sql.PreparedStatement
Throws:
java.sql.SQLException - this is never thrown

close

public void close()
 throws java.sql.SQLException
Closes the statement and any associated ResultSet.

Throws:
java.sql.SQLException -  
Overrides:
close in class RealSQLStatement


execute

public boolean execute()
 throws java.sql.SQLException
Executes the stored procedure with its current values. Any currently outstanding resultset is closed prior to execution.
Specified by:
execute in interface java.sql.PreparedStatement
Returns:
true if the stored procedure generated a result set
Throws:
java.sql.SQLException - an error occurred executing the SQL.

executeQuery

public java.sql.ResultSet executeQuery()
 throws java.sql.SQLException
Executes the stored query with its current values. Any currently outstanding resultset is closed prior to execution.
Specified by:
executeQuery in interface java.sql.PreparedStatement
Returns:
the results of the stored procedure.
Throws:
java.sql.SQLException - an error occurred executing the SQL.

executeUpdate

public int executeUpdate()
 throws java.sql.SQLException
Executes the stored update with its current values. Any currently outstanding resultset is closed prior to execution.
Specified by:
executeUpdate in interface java.sql.PreparedStatement
Returns:
the number of rows affected by the update.
Throws:
java.sql.SQLException - an error occurred executing the SQL.

getMetaData

public java.sql.ResultSetMetaData getMetaData()
 throws java.sql.SQLException
JDBC 2.0 Gets the number, types and properties of a ResultSet's columns.
Specified by:
getMetaData in interface java.sql.PreparedStatement
Returns:
ResultSetMetaData the description of the ResultSet's columns.
Throws:
java.sql.SQLException -  

setArray

public void setArray(int index,
 java.sql.Array sqlarray)
 throws java.sql.SQLException
Currently not supported by the RealSQL-JDBC driver.

JDBC 2.0 Sets an Array parameter.

Specified by:
setArray in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
sqlarray - object representing an SQL array.
Throws:
java.sql.SQLException - IM001 - "Driver does not support this function".


setAsciiStream

public void setAsciiStream(int index,
 java.io.InputStream is,
 int len)
 throws java.sql.SQLException
Sets the parameter to the data in the specified stream.
Specified by:
setAsciiStream in interface java.sql.PreparedStatement
Parameters:
index - the parameter to set
is - the input stream containing the data
len - the number of bytes in the stream
Throws:
java.sql.SQLException - an error occurred setting the parameter

setBigDecimal

public void setBigDecimal(int index,
 java.math.BigDecimal bd)
 throws java.sql.SQLException
Sets the specified parameter to a BigDecimal value.
Specified by:
setBigDecimal in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set
bd - the BigDecimal value
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setBinaryStream

public void setBinaryStream(int index,
 java.io.InputStream is,
 int len)
 throws java.sql.SQLException
Currently not supported by the RealSQL-JDBC driver.

Sets the parameter to the data in the specified stream.

Specified by:
setBinaryStream in interface java.sql.PreparedStatement
Parameters:
index - the parameter to set
is - the input stream containing the data
len - the number of bytes in the stream
Throws:
java.sql.SQLException - IM001 - "Driver does not support this function".


setBlob

public void setBlob(int index,
 java.sql.Blob b)
 throws java.sql.SQLException
Currently not supported by the RealSQL-JDBC driver.

Sets the specified parameter to a Blob value.

Specified by:
setBlob in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set
b - the Blob value
Throws:
java.sql.SQLException - IM001 - "Driver does not support this function".


setBoolean

public void setBoolean(int index,
 boolean b)
 throws java.sql.SQLException
Currently not supported by the RealSQL-JDBC driver.

Sets the specified parameter to a boolean value. This will set the column to the integer value 1 for true or 0 for false.

Specified by:
setBoolean in interface java.sql.PreparedStatement
Parameters:
index - the parameter to set.
b - the value to set.
Throws:
java.sql.SQLException - an error occurred setting the parameter


setByte

public void setByte(int index,
 byte b)
 throws java.sql.SQLException
Sets the specified parameter to the specified byte value.
Specified by:
setByte in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set
b - the byte value.
Throws:
java.sql.SQLException - an error occurred setting the parameter

setBytes

public void setBytes(int index,
 byte[] barray)
 throws java.sql.SQLException
Sets the specified parameter to the specified byte value.
Specified by:
setBytes in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
barray - the byte array value.
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setCharacterStream

public void setCharacterStream(int index,
 java.io.Reader in,
 int len)
 throws java.sql.SQLException
Currently not supported by the RealSQL-JDBC driver.

JDBC 2.0 Sets the designated parameter to the given Reader object, which is the given number of characters long.

Specified by:
setCharacterStream in interface java.sql.PreparedStatement
Parameters:
index - the parameter to set.
in - the stream containing the data.
len - the number of bytes in the stream.
Throws:
java.sql.SQLException - IM001 - "Driver does not support this function".


setClob

public void setClob(int index,
 java.sql.Clob c)
 throws java.sql.SQLException
Currently not supported by the RealSQL-JDBC driver.

Sets the specified parameter to a Clob value.

Specified by:
setClob in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set
c - the Clob value
Throws:
java.sql.SQLException - IM001 - "Driver does not support this function".


setDate

public void setDate(int index,
 java.sql.Date d)
 throws java.sql.SQLException
Sets the designated parameter to a java.sql.Date value. The driver converts this to an SQL DATE in the form yyyy-MM-dd prior to sending it to the database.
Specified by:
setDate in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
d - the Date value to set.
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setDate

public void setDate(int index,
 java.sql.Date d,
 java.util.Calendar cal)
 throws java.sql.SQLException
JDBC 2.0 Sets the designated parameter to a java.sql.Date value, using the given Calendar object. The driver converts this to an SQL DATE in the form yyyy-MM-dd prior to sending it to the database.
Specified by:
setDate in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
d - the Date value to set.
cal - the Calendar to use.
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setDouble

public void setDouble(int index,
 double d)
 throws java.sql.SQLException
Sets the specified parameter to a double value.
Specified by:
setDouble in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set
d - the value to set.
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setFloat

public void setFloat(int index,
 float f)
 throws java.sql.SQLException
Sets the specified parameter to a float value.
Specified by:
setFloat in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
f - the value to set.
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setInt

public void setInt(int index,
 int i)
 throws java.sql.SQLException
Sets the specified parameter to an int value.
Specified by:
setInt in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
i - the value to set.
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setLong

public void setLong(int index,
 long l)
 throws java.sql.SQLException
Sets the specified parameter to a long value.
Specified by:
setLong in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
l - the value to set.
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setNull

public void setNull(int index,
 int type)
 throws java.sql.SQLException
Sets the specified parameter to a null value.
Specified by:
setNull in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
type - the SQL type of the value to be set.
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setNull

public void setNull(int index,
 int type,
 java.lang.String tname)
 throws java.sql.SQLException
JDBC 2.0 Sets the specified parameter to a null value. Note, Reality does not support UDT's and therefore the tname parameter is ignored.
Specified by:
setNull in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
type - the SQL type of the value to be set - not used.
tname - the name of the UDT - not used.
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setObject

public void setObject(int index,
 java.lang.Object obj)
 throws java.sql.SQLException
Sets the specified parameter to a Java object value using the standard mapping from Java Object types to SQL types. The java object is converted to the corresponding SQL type before being sent to the database.
Specified by:
setObject in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
obj - the object to be set.
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setObject

public void setObject(int index,
 java.lang.Object obj,
 int targetSqlType)
 throws java.sql.SQLException
Sets the specified parameter to a Java object value according to the SQL type specified.
Specified by:
setObject in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
ob - the object to be set.
type - the target SQL type.
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setObject

public void setObject(int index,
 java.lang.Object obj,
 int targetSqlType,
 int scale)
 throws java.sql.SQLException
Sets the specified parameter to a Java object value according to the SQL type specified.
Specified by:
setObject in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set
obj - the object to be set.
type - the target SQL type.
scale - this is ignored.
Throws:
java.sql.SQLException - an error occurred setting the parameter

setRef

public void setRef(int index,
 java.sql.Ref r)
 throws java.sql.SQLException
Currently not supported by the RealSQL-JDBC driver.

Sets the specified parameter to a Ref value.

Specified by:
setRef in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
r - the Ref value.
Throws:
java.sql.SQLException - IM001 - "Driver does not support this function".


setShort

public void setShort(int index,
 short s)
 throws java.sql.SQLException
Sets the specified parameter to a short value.
Specified by:
setShort in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
s - the value to set.
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setString

public void setString(int index,
 java.lang.String str)
 throws java.sql.SQLException
Sets the specified parameter to a String value.
Specified by:
setString in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
str - the value to set.
Throws:
java.sql.SQLException - an error occurred setting the parameter.

setTime

public void setTime(int index,
 java.sql.Time t)
 throws java.sql.SQLException
Sets the specified parameter to a Time value.
Specified by:
setTime in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
t - the value to set.
Throws:
java.sql.SQLException - if error occurred setting parameter.

setTime

public void setTime(int index,
 java.sql.Time t,
 java.util.Calendar cal)
 throws java.sql.SQLException
Sets the specified parameter to a Time value.
Specified by:
setTime in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
t - the value to set.
cal - the Calendar to use.
Throws:
java.sql.SQLException - if error occurred setting parameter.

setTimestamp

public void setTimestamp(int index,
 java.sql.Timestamp t)
 throws java.sql.SQLException
Sets the specified parameter to a Timestamp value.
Specified by:
setTimestamp in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
t - the value to set.
Throws:
java.sql.SQLException - if error occurred setting parameter.

setTimestamp

public void setTimestamp(int index,
 java.sql.Timestamp t,
 java.util.Calendar cal)
 throws java.sql.SQLException
Sets the specified parameter to a Timestamp value.
Specified by:
setTimestamp in interface java.sql.PreparedStatement
Parameters:
index - the parameter to be set.
t - the value to set.
cal - the Calendar to use.
Throws:
java.sql.SQLException - if error occurred setting parameter.

setUnicodeStream

public void setUnicodeStream(int index,
 java.io.InputStream is,
 int len)
 throws java.sql.SQLException
Deprecated. use setCharacterStream()
Currently not supported by the RealSQL-JDBC driver.

Sets the specified parameter to the data contained in the specified unicode stream.

Specified by:
setUnicodeStream in interface java.sql.PreparedStatement
Parameters:
index - the parameter being set
is - the input stream with the data.
len - the number of bytes to be read.
Throws:
java.sql.SQLException - IM001 - "Driver does not support this function".


validateIndex

protected void validateIndex(int index)
 throws java.sql.SQLException
Verifies that the specified index is valid for this stored procedure.
Parameters:
index - the parameter number to be tested
Throws:
java.sql.SQLException - the specified parameter is invalid

sendParams

protected void sendParams()
 throws java.sql.SQLException
Forwards the values of all registered INPUT parameters to the Reality server, this must be called prior to executing the stored procedure.
Throws:
java.sql.SQLException -  

getInputParam

protected RealParamDatagetInputParam(int index)
Retrieves the input parameter specified by the index.
Returns:
RealParamData object represented by specified index.

getParamCount

protected int getParamCount()
Retrieves the total number of parameters used by this stored procedure.
Returns:
parameter count.