Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class com.imaginary.sql.msql.MsqlPreparedStatement

java.lang.Object
  |
  +--com.imaginary.sql.msql.MsqlStatement
        |
        +--com.imaginary.sql.msql.MsqlPreparedStatement

public class MsqlPreparedStatement
extends MsqlStatement
implements java.sql.PreparedStatement
The MsqlPreparedStatement is an mSQL implementation of the JDBC PreparedStatement interface. Specifically, it enables an application to execute the same SQL over and over again without repeatedly writing logic to build the SQL statements. Instead, the application just passes new inputs. Because mSQL is completely unaware of the concept of a PreparedStatement, the mSQL driver basically hacks it by doing its own parsing and management. There is still a huge advantage to using the PreparedStatement over a regular statement in that you never have to worry about date or String formatting.
Last modified $Date: 1999/07/06 05:56:08 $

Version:
$Revision: 1.6 $
Author:
George Reese (borg@imaginary.com)

Fields inherited from class com.imaginary.sql.msql.MsqlStatement
log
 
Method Summary
void addBatch()
          Adds the current parameter values to the batch list and then clears the parameters for the next set of parameters.
void clearParameters()
          Clears the current parameters.
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.
java.sql.ResultSetMetaData getMetaData()
          This errors out because I have not yet figured out a good way to implement this for mSQL.
void setArray(int ind, java.sql.Array arr)
          This is not really supported, but it tries.
void setAsciiStream(int ind, java.io.InputStream in, int len)
          Sets the parameter to the data in the specified stream.
void setBigDecimal(int ind, java.math.BigDecimal bd)
          Sets the specified parameter to a BigDecimal value.
void setBinaryStream(int ind, java.io.InputStream in, int len)
          Sets the parameter to the data in the specified stream.
void setBlob(int ind, java.sql.Blob b)
          Sets the specified parameter to a Blob value.
void setBoolean(int ind, boolean b)
          Sets the specified parameter to a boolean value.
void setByte(int ind, byte b)
          Sets the specified parameter to the specified byte value.
void setBytes(int ind, byte[] data)
          Sets the specified parameter to the specified byte value.
void setCharacterStream(int ind, java.io.Reader in, int len)
          Sets the parameter to the data in the specified stream.
void setClob(int ind, java.sql.Clob c)
          Sets the specified parameter to a Clob value.
void setDate(int ind, java.sql.Date d)
          Sets the specified parameter to a date value stored in the mSQL database as a string in the form dd-MMM-yyyy.
void setDate(int ind, java.sql.Date d, java.util.Calendar cal)
          Sets the specified parameter to a date value stored in the mSQL database as a string in the form dd-MMM-yyyy.
void setDouble(int ind, double d)
          Sets the specified parameter to a double value.
void setFloat(int ind, float f)
          Sets the specified parameter to a float value.
void setInt(int ind, int x)
          Sets the specified parameter to an int value.
void setLong(int ind, long l)
          Sets the specified parameter to a long value.
void setNull(int ind, int type)
          Sets the specified parameter to a null value.
void setNull(int ind, int type, java.lang.String tname)
          Sets the specified parameter to a null value.
void setObject(int ind, java.lang.Object ob)
          Sets the specified parameter to a Java object value by calling ob.toString().
void setObject(int ind, java.lang.Object ob, int type)
          Sets the specified parameter to a Java object value according to the SQL type specified.
void setObject(int ind, java.lang.Object ob, int type, int scale)
          Sets the specified parameter to a Java object value according to the SQL type specified.
void setRef(int ind, java.sql.Ref r)
          Sets the specified parameter to a Ref value.
void setShort(int ind, short s)
          Sets the specified parameter to a short value.
void setString(int ind, java.lang.String str)
          Sets the specified parameter to a String value.
void setTime(int ind, java.sql.Time t)
          Sets the specified parameter to a Time value.
void setTime(int ind, java.sql.Time t, java.util.Calendar cal)
          Sets the specified parameter to a Time value.
void setTimestamp(int ind, java.sql.Timestamp t)
          Sets the specified parameter to a Timestamp value.
void setTimestamp(int ind, java.sql.Timestamp t, java.util.Calendar cal)
          Sets the specified parameter to a Timestamp value.
void setUnicodeStream(int ind, java.io.InputStream in, int len)
          Deprecated. Sets the specified parameter to the data contained in the specified unicode stream.
 
Methods inherited from class com.imaginary.sql.msql.MsqlStatement
addBatch, cancel, clearBatch, clearWarnings, close, executeBatch, execute, executeQuery, executeUpdate, getConnection, getEncoding, getFetchDirection, getFetchSize, getMaxFieldSize, getMaxRows, getMoreResults, getQueryTimeout, getResultSetConcurrency, getResultSet, getResultSetType, getUpdateCount, getWarnings, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Method Detail

addBatch

public void addBatch()
             throws java.sql.SQLException
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 - could not add the current parameters to the batch list

clearParameters

public void clearParameters()
                    throws java.sql.SQLException
Clears the current parameters.
Specified by:
clearParameters() in interface java.sql.PreparedStatement
Throws:
java.sql.SQLException - this is never thrown

execute

public boolean execute()
               throws java.sql.SQLException
Executes the stored procedure with its current values.
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.
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.
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
This errors out because I have not yet figured out a good way to implement this for mSQL.
Specified by:
getMetaData() in interface java.sql.PreparedStatement
Returns:
ResultSetMetaData representing result sets for this stored procedure
Throws:
java.sql.SQLException - this is always thrown

setArray

public void setArray(int ind,
                     java.sql.Array arr)
             throws java.sql.SQLException
This is not really supported, but it tries.
Specified by:
setArray(int, java.sql.Array) in interface java.sql.PreparedStatement
Parameters:
ind - the parameter to be set
arr - the array value
Throws:
java.sql.SQLException - an error occurred setting the parameter

setAsciiStream

public void setAsciiStream(int ind,
                           java.io.InputStream in,
                           int len)
                   throws java.sql.SQLException
Sets the parameter to the data in the specified stream.
Specified by:
setAsciiStream(int, java.io.InputStream, int) in interface java.sql.PreparedStatement
Parameters:
ind - the parameter to set
in - the 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 ind,
                          java.math.BigDecimal bd)
                  throws java.sql.SQLException
Sets the specified parameter to a BigDecimal value.
Specified by:
setBigDecimal(int, java.math.BigDecimal) in interface java.sql.PreparedStatement
Parameters:
ind - the parameter to be set
db - the BigDecimal value
Throws:
java.sql.SQLException - an error occurred setting the parameter

setBinaryStream

public void setBinaryStream(int ind,
                            java.io.InputStream in,
                            int len)
                    throws java.sql.SQLException
Sets the parameter to the data in the specified stream.
Specified by:
setBinaryStream(int, java.io.InputStream, int) in interface java.sql.PreparedStatement
Parameters:
ind - the parameter to set
in - the stream containing the data
len - the number of bytes in the stream
Throws:
java.sql.SQLException - this is always thrown as mSQL has no binary object support

setBlob

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

setBoolean

public void setBoolean(int ind,
                       boolean b)
               throws java.sql.SQLException
Sets the specified parameter to a boolean value. Specifically, it will set the column to the int 1 foor true or 0 for false.
Specified by:
setBoolean(int, boolean) in interface java.sql.PreparedStatement
Parameters:
ind - the parameter to set
b - the value to set
Throws:
java.sql.SQLException - an error occurred setting the parameter

setByte

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

setBytes

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

setCharacterStream

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

setClob

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

setDate

public void setDate(int ind,
                    java.sql.Date d)
            throws java.sql.SQLException
Sets the specified parameter to a date value stored in the mSQL database as a string in the form dd-MMM-yyyy.
Specified by:
setDate(int, java.sql.Date) in interface java.sql.PreparedStatement
Parameters:
ind - 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 ind,
                    java.sql.Date d,
                    java.util.Calendar cal)
            throws java.sql.SQLException
Sets the specified parameter to a date value stored in the mSQL database as a string in the form dd-MMM-yyyy.
Specified by:
setDate(int, java.sql.Date, java.util.Calendar) in interface java.sql.PreparedStatement
Parameters:
ind - 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 ind,
                      double d)
              throws java.sql.SQLException
Sets the specified parameter to a double value.
Specified by:
setDouble(int, double) in interface java.sql.PreparedStatement
Parameters:
ind - 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 ind,
                     float f)
             throws java.sql.SQLException
Sets the specified parameter to a float value.
Specified by:
setFloat(int, float) in interface java.sql.PreparedStatement
Parameters:
ind - 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 ind,
                   int x)
           throws java.sql.SQLException
Sets the specified parameter to an int value.
Specified by:
setInt(int, int) in interface java.sql.PreparedStatement
Parameters:
ind - the parameter to be set
x - the value to set
Throws:
java.sql.SQLException - an error occurred setting the parameter

setLong

public void setLong(int ind,
                    long l)
            throws java.sql.SQLException
Sets the specified parameter to a long value.
Specified by:
setLong(int, long) in interface java.sql.PreparedStatement
Parameters:
ind - 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 ind,
                    int type)
            throws java.sql.SQLException
Sets the specified parameter to a null value.
Specified by:
setNull(int, int) in interface java.sql.PreparedStatement
Parameters:
ind - 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 ind,
                    int type,
                    java.lang.String tname)
            throws java.sql.SQLException
Sets the specified parameter to a null value.
Parameters:
ind - the parameter to be set
type - the SQL type of the value to be set
tname - the name of the UDT
Throws:
java.sql.SQLException - an error occurred setting the parameter

setObject

public void setObject(int ind,
                      java.lang.Object ob)
              throws java.sql.SQLException
Sets the specified parameter to a Java object value by calling ob.toString().
Specified by:
setObject(int, java.lang.Object) in interface java.sql.PreparedStatement
Parameters:
ind - the parameter to be set
ob - the object to be set
Throws:
java.sql.SQLException - an error occurred setting the parameter

setObject

public void setObject(int ind,
                      java.lang.Object ob,
                      int type)
              throws java.sql.SQLException
Sets the specified parameter to a Java object value according to the SQL type specified.
Specified by:
setObject(int, java.lang.Object, int) in interface java.sql.PreparedStatement
Parameters:
ind - 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 ind,
                      java.lang.Object ob,
                      int type,
                      int scale)
              throws java.sql.SQLException
Sets the specified parameter to a Java object value according to the SQL type specified.
Specified by:
setObject(int, java.lang.Object, int, int) in interface java.sql.PreparedStatement
Parameters:
ind - the parameter to be set
ob - 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 ind,
                   java.sql.Ref r)
           throws java.sql.SQLException
Sets the specified parameter to a Ref value.
Specified by:
setRef(int, java.sql.Ref) in interface java.sql.PreparedStatement
Parameters:
ind - the parameter to be set
r - the Ref value
Throws:
java.sql.SQLException - an error occurred setting the parameter

setShort

public void setShort(int ind,
                     short s)
             throws java.sql.SQLException
Sets the specified parameter to a short value.
Specified by:
setShort(int, short) in interface java.sql.PreparedStatement
Parameters:
ind - 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 ind,
                      java.lang.String str)
              throws java.sql.SQLException
Sets the specified parameter to a String value.
Specified by:
setString(int, java.lang.String) in interface java.sql.PreparedStatement
Parameters:
ind - 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 ind,
                    java.sql.Time t)
            throws java.sql.SQLException
Sets the specified parameter to a Time value.
Specified by:
setTime(int, java.sql.Time) in interface java.sql.PreparedStatement
Parameters:
ind - the parameter to be set
t - the value to set
Throws:
java.sql.SQLException - an error occurred setting the parameter

setTime

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

setTimestamp

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

setTimestamp

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

setUnicodeStream

public void setUnicodeStream(int ind,
                             java.io.InputStream in,
                             int len)
                     throws java.sql.SQLException
Deprecated. use setCharacterStream()
Sets the specified parameter to the data contained in the specified unicode stream.
Specified by:
setUnicodeStream(int, java.io.InputStream, int) in interface java.sql.PreparedStatement
Parameters:
ind - the parameter being set
in - the stream with the data
len - the number of bytes to be read
Throws:
java.sql.SQLException - an error occurred setting the parameter

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD