com.fatwire.cs.core.db
Class StatementParam

java.lang.Object
  extended by com.fatwire.cs.core.db.StatementParam

public final class StatementParam
extends java.lang.Object

This class represents the data supplied to the execution of a prepared statement. The data is substituted in place of placeholders while executing the prepared statement.

The JDBC specifications mandate the following mapping between Java Object types and native SQL types.

Java Object Type JDBC Type
String CHAR, VARCHAR, or LONGVARCHAR
java.math.BigDecimal NUMERIC
Boolean BIT or BOOLEAN
Integer INTEGER
Long BIGINT
Float REAL
Double DOUBLE
byte[] BINARY, VARBINARY, or LONGVARBINARY
java.sql.Date DATE
java.sql.Time TIME
java.sql.Timestamp TIMESTAMP
Clob CLOB
Blob BLOB
Array ARRAY
Struct STRUCT
Ref REF
java.net.URL DATALINK
Java class JAVA_OBJECT

Implicit conversions from one type to another is attempted at run time, per JDBC specifications.

Most setX methods of this class work with primitives, when they exist for a supported Java object (above). Addtional methods exist to correspond to those types that do not resolve to primitives.

setX methods do not exist for Array, Struct, Ref, URL and Java Class not exist (as of this writing, it is not known how well drivers comply to them). Clob and Blob are do not have corresponding setX (for now, at least).


Method Summary
 java.lang.Object getAt(int position)
          Returns data for a given position
 int getPositionsCount()
          Returns the number of positions (placeholders)
 boolean isComplete()
          Indicates if this instance is completely formed (bound with data).
 void setBigDecimal(int parameterIndex, java.math.BigDecimal value)
          Sets a BigDecimal value at a given position
 void setBinary(int parameterIndex, byte[] binData)
          Sets Binary value for a given position
 void setBoolean(int parameterIndex, boolean bValue)
          Sets boolean value at a given index
 void setByte(int parameterIndex, byte byteVal)
          Sets byte at a given position
 void setDate(int parameterIndex, java.sql.Date dtValue)
          Sets a Date vlaue a given position
 void setDouble(int parameterIndex, double dDoubleVal)
          Sets a double value at a given position
 void setFloat(int parameterIndex, float fFloatVal)
          Sets a float value at a given position
 void setInt(int parameterIndex, int iIntVal)
          Sets an int value at a given position
 void setLong(int parameterIndex, long lLongVal)
          Sets a long value at a given position
 void setNull(int pos)
          Sets 'null' at a given position
 void setShort(int parameterIndex, short shortVal)
          Sets a short value at a given position
 void setString(int parameterIndex, java.lang.String sValue)
          Sets a String value at a given position
 void setTime(int parameterIndex, java.sql.Time time)
          Sets Time value for a given position
 void setTimeStamp(int parameterIndex, java.sql.Timestamp time)
          Sets Timestamp value for a given position
 java.lang.String toString()
          Useful String representation of the object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

setNull

public void setNull(int pos)
Sets 'null' at a given position

Parameters:
pos - position (0 based)

setBoolean

public void setBoolean(int parameterIndex,
                       boolean bValue)
Sets boolean value at a given index

Parameters:
parameterIndex - position (0 based)
bValue - boolean value to set

setByte

public void setByte(int parameterIndex,
                    byte byteVal)
Sets byte at a given position

Parameters:
parameterIndex - position (0 based)
byteVal - byte value to set

setShort

public void setShort(int parameterIndex,
                     short shortVal)
Sets a short value at a given position

Parameters:
parameterIndex - position (0 based)
shortVal - short value to set

setInt

public void setInt(int parameterIndex,
                   int iIntVal)
Sets an int value at a given position

Parameters:
parameterIndex - position (0 based)
iIntVal - int value to set

setLong

public void setLong(int parameterIndex,
                    long lLongVal)
Sets a long value at a given position

Parameters:
parameterIndex - position (0 based)
lLongVal - long value to set

setFloat

public void setFloat(int parameterIndex,
                     float fFloatVal)
Sets a float value at a given position

Parameters:
parameterIndex - position (0 based)
fFloatVal - float value to set

setDouble

public void setDouble(int parameterIndex,
                      double dDoubleVal)
Sets a double value at a given position

Parameters:
parameterIndex - position (0 based)
dDoubleVal - double value to set

setBigDecimal

public void setBigDecimal(int parameterIndex,
                          java.math.BigDecimal value)
Sets a BigDecimal value at a given position

Parameters:
parameterIndex - position (0 based)
value - long value to set

setString

public void setString(int parameterIndex,
                      java.lang.String sValue)
Sets a String value at a given position

Parameters:
parameterIndex - position (0 based)
sValue - String value to set

setDate

public void setDate(int parameterIndex,
                    java.sql.Date dtValue)
Sets a Date vlaue a given position

Parameters:
parameterIndex - position (0 based)
dtValue - Date value to set

setTime

public void setTime(int parameterIndex,
                    java.sql.Time time)
Sets Time value for a given position

Parameters:
parameterIndex - position (0 based)
time - java.sql.Time value to set

setTimeStamp

public void setTimeStamp(int parameterIndex,
                         java.sql.Timestamp time)
Sets Timestamp value for a given position

Parameters:
parameterIndex - position (0 based)
time - java.sql.Timestamp value to set

setBinary

public void setBinary(int parameterIndex,
                      byte[] binData)
Sets Binary value for a given position

Parameters:
parameterIndex - position (0 based)
binData - binary data to set

isComplete

public boolean isComplete()
Indicates if this instance is completely formed (bound with data).

Returns:
true if all placeholders have been assigned values, false otherwise.

getAt

public java.lang.Object getAt(int position)
Returns data for a given position

Parameters:
position - index of placeholder
Returns:
data at given position, can be null.

getPositionsCount

public int getPositionsCount()
Returns the number of positions (placeholders)

Returns:
returns the number of placeholders this instance is created with

toString

public java.lang.String toString()
Useful String representation of the object

Overrides:
toString in class java.lang.Object
Returns:
String with all interesting info about the object.