litebase
Class PreparedStatement

java.lang.Object
  |
  +--litebase.PreparedStatement

public final class PreparedStatement
extends java.lang.Object

Represents a SQL Statement that can be prepared (compiled) once and executed many times with different parameter values.


Constructor Summary
protected PreparedStatement(LitebaseConnection driver)
          Basic constructor
 
Method Summary
 void clearParameters()
          This method clears all of the input parameter that have been set on this statement.
 ResultSet executeQuery()
          This method executes a prepared SQL query and returns its ResultSet.
 int executeUpdate()
          This method executes an SQL INSERT, UPDATE or DELETE statement.
protected  void prepare(java.lang.String sql)
          Prepare a SQL statement.
 void setDate(int index, waba.util.Date date)
          it formats the Date d in a string "YYYY/MM/DD" and calls the setString IMPORTANT: You must use care with the constructor “new Date()”.
 void setDateTime(int index, waba.util.Date date, waba.sys.Time time)
          It formats the Date d and the Time t in a string "YYYY/MM/DD HH:MM:SS:ZZZ" and calls the setString IMPORTANT: You must use care with the constructor “new Date()”.
 void setDouble(int index, double value)
          This method sets the specified parameter from the given Java double value.
 void setInt(int index, int value)
          This method sets the specified parameter from the given Java int value.
 void setLong(int index, long value)
          This method sets the specified parameter from the given Java long value.
 void setString(int index, java.lang.String value)
          This method sets the specified parameter from the given Java String value.
 void setTime(int index, waba.sys.Time time)
          It formats the Time t in a string "YYYY/MM/DD HH:MM:SS:ZZZ" and calls the setString
 java.lang.String toString()
          Returns the sql used in this statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PreparedStatement

protected PreparedStatement(LitebaseConnection driver)
Basic constructor
Parameters:
driver - the LitebaseConnection that will process the statement
Method Detail

prepare

protected void prepare(java.lang.String sql)
                throws SQLParseException
Prepare a SQL statement.
Parameters:
sql - the SQL expression
Throws:
SQLParseException - if a parsing error occurs.

executeQuery

public ResultSet executeQuery()
                       throws DriverException
This method executes a prepared SQL query and returns its ResultSet.
Returns:
The ResultSet of the SQL statement.
Throws:
DriverException - If an error occurs.

executeUpdate

public int executeUpdate()
                  throws DriverException
This method executes an SQL INSERT, UPDATE or DELETE statement. SQL statements that return nothing such as SQL DDL statements can be executed.
Returns:
The result is either the row count for INSERT, UPDATE or DELETE statements; or 0 for SQL statements that return nothing.
Throws:
DriverException - If an error occurs.

setInt

public void setInt(int index,
                   int value)
            throws DriverException
This method sets the specified parameter from the given Java int value.
Parameters:
index - The index of the parameter value to set, starting from 0.
value - The value of the parameter.
Throws:
DriverException - If an error occurs.

setLong

public void setLong(int index,
                    long value)
             throws DriverException
This method sets the specified parameter from the given Java long value.
Parameters:
index - The index of the parameter value to set, starting from 0.
value - The value of the parameter.
Throws:
DriverException - If an error occurs.

setDouble

public void setDouble(int index,
                      double value)
               throws DriverException
This method sets the specified parameter from the given Java double value.
Parameters:
index - The index of the parameter value to set, starting from 0.
value - The value of the parameter.
Throws:
DriverException - If an error occurs.

setString

public void setString(int index,
                      java.lang.String value)
               throws DriverException
This method sets the specified parameter from the given Java String value.
Parameters:
index - The index of the parameter value to set, starting from 0.
value - The value of the parameter. DO NOT SURROUND IT WITH '!.
Throws:
DriverException - If an error occurs.

setDate

public void setDate(int index,
                    waba.util.Date date)
             throws DriverException
it formats the Date d in a string "YYYY/MM/DD" and calls the setString IMPORTANT: You must use care with the constructor “new Date()”. Some devices can construct different dates, according to the device's date format. For example, the constructor 'new Date(“12/09/2006”)', depending on the device's date format, can generate a date like “12 of September of 2006” or “09 of December of 2006”. To avoid this, use the constructor new Date(, waba.sys.Settings.DATE_XXX) instead, where waba.sys.Settings.DATE_XXX is a date format parameter that must be one of the waba.sys.Settings.DATE_XXX constants.

setDateTime

public void setDateTime(int index,
                        waba.util.Date date,
                        waba.sys.Time time)
                 throws DriverException
It formats the Date d and the Time t in a string "YYYY/MM/DD HH:MM:SS:ZZZ" and calls the setString IMPORTANT: You must use care with the constructor “new Date()”. Some devices can construct different dates, according to the device's date format. For example, the constructor 'new Date(“12/09/2006”)', depending on the device's date format, can generate a date like “12 of September of 2006” or “09 of December of 2006”. To avoid this, use the constructor new Date(, waba.sys.Settings.DATE_XXX) instead, where waba.sys.Settings.DATE_XXX is a date format parameter that must be one of the waba.sys.Settings.DATE_XXX constants.

setTime

public void setTime(int index,
                    waba.sys.Time time)
             throws DriverException
It formats the Time t in a string "YYYY/MM/DD HH:MM:SS:ZZZ" and calls the setString

clearParameters

public void clearParameters()
                     throws DriverException
This method clears all of the input parameter that have been set on this statement.
Throws:
DriverException - If an error occurs.

toString

public java.lang.String toString()
Returns the sql used in this statement. If logging is disabled, returns the sql without the arguments. If logging is enabled, returns the real sql, filled with the arguments.
Overrides:
toString in class java.lang.Object