SQLite
Class Stmt

java.lang.Object
  extended by SQLite.Stmt

public class Stmt
extends java.lang.Object

Class to represent compiled SQLite3 statement. Note, that all native methods of this class are not synchronized, i.e. it is up to the caller to ensure that only one thread is in these methods at any one time.


Field Summary
protected  int error_code
          Internal last error code for prepare()/step() methods.
private  long handle
          Internal handle for the SQLite3 statement.
 
Constructor Summary
Stmt()
           
 
Method Summary
 int bind_parameter_count()
          Return number of parameters in compiled SQLite3 statement.
 int bind_parameter_index(java.lang.String name)
          Return index of named parameter in compiled SQLite3 statement.
 java.lang.String bind_parameter_name(int pos)
          Return name of parameter in compiled SQLite3 statement.
 void bind_zeroblob(int pos, int length)
          Bind positional zero'ed blob to compiled SQLite3 statement.
 void bind(int pos)
          Bind positional SQL null to compiled SQLite3 statement.
 void bind(int pos, byte[] value)
          Bind positional byte array to compiled SQLite3 statement.
 void bind(int pos, double value)
          Bind positional double value to compiled SQLite3 statement.
 void bind(int pos, int value)
          Bind positional integer value to compiled SQLite3 statement.
 void bind(int pos, long value)
          Bind positional long value to compiled SQLite3 statement.
 void bind(int pos, java.lang.String value)
          Bind positional String to compiled SQLite3 statement.
 void clear_bindings()
          Clear all bound parameters of the compiled SQLite3 statement.
 void close()
          Close the compiled SQLite3 statement.
 byte[] column_bytes(int col)
          Retrieve blob column from exec'ed SQLite3 statement.
 int column_count()
          Retrieve number of columns of exec'ed SQLite3 statement.
 java.lang.String column_database_name(int col)
          Return database name of column of SQLite3 statement.
 java.lang.String column_decltype(int col)
          Return declared column type of SQLite3 statement.
 double column_double(int col)
          Retrieve double column from exec'ed SQLite3 statement.
 int column_int(int col)
          Retrieve integer column from exec'ed SQLite3 statement.
 long column_long(int col)
          Retrieve long column from exec'ed SQLite3 statement.
 java.lang.String column_origin_name(int col)
          Return origin column name of column of SQLite3 statement.
 java.lang.String column_string(int col)
          Retrieve string column from exec'ed SQLite3 statement.
 java.lang.String column_table_name(int col)
          Return table name of column of SQLite3 statement.
 int column_type(int col)
          Retrieve column type from exec'ed SQLite3 statement.
 java.lang.Object column(int col)
          Retrieve column data as object from exec'ed SQLite3 statement.
protected  void finalize()
          Destructor for object.
private static void internal_init()
          Internal native initializer.
 boolean prepare()
          Prepare the next SQL statement for the Stmt instance.
 void reset()
          Reset the compiled SQLite3 statement without clearing parameter bindings.
 int status(int op, boolean flg)
          Return statement status information.
 boolean step()
          Perform one step of compiled SQLite3 statement.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

error_code

protected int error_code
Internal last error code for prepare()/step() methods.


handle

private long handle
Internal handle for the SQLite3 statement.

Constructor Detail

Stmt

public Stmt()
Method Detail

bind_parameter_count

public int bind_parameter_count()
                         throws Exception
Return number of parameters in compiled SQLite3 statement.

Returns:
int number of parameters
Throws:
Exception

bind_parameter_index

public int bind_parameter_index(java.lang.String name)
                         throws Exception
Return index of named parameter in compiled SQLite3 statement.

Parameters:
name - of parameter
Returns:
int index of parameter, 1-based
Throws:
Exception

bind_parameter_name

public java.lang.String bind_parameter_name(int pos)
                                     throws Exception
Return name of parameter in compiled SQLite3 statement.

Parameters:
pos - parameter index, 1-based
Returns:
String parameter name
Throws:
Exception

bind_zeroblob

public void bind_zeroblob(int pos,
                          int length)
                   throws Exception
Bind positional zero'ed blob to compiled SQLite3 statement.

Parameters:
pos - parameter index, 1-based
length - byte size of zero blob
Throws:
Exception

bind

public void bind(int pos)
          throws Exception
Bind positional SQL null to compiled SQLite3 statement.

Parameters:
pos - parameter index, 1-based
Throws:
Exception

bind

public void bind(int pos,
                 byte[] value)
          throws Exception
Bind positional byte array to compiled SQLite3 statement.

Parameters:
pos - parameter index, 1-based
value - value of parameter, may be null
Throws:
Exception

bind

public void bind(int pos,
                 double value)
          throws Exception
Bind positional double value to compiled SQLite3 statement.

Parameters:
pos - parameter index, 1-based
value - value of parameter
Throws:
Exception

bind

public void bind(int pos,
                 int value)
          throws Exception
Bind positional integer value to compiled SQLite3 statement.

Parameters:
pos - parameter index, 1-based
value - value of parameter
Throws:
Exception

bind

public void bind(int pos,
                 long value)
          throws Exception
Bind positional long value to compiled SQLite3 statement.

Parameters:
pos - parameter index, 1-based
value - value of parameter
Throws:
Exception

bind

public void bind(int pos,
                 java.lang.String value)
          throws Exception
Bind positional String to compiled SQLite3 statement.

Parameters:
pos - parameter index, 1-based
value - value of parameter, may be null
Throws:
Exception

clear_bindings

public void clear_bindings()
                    throws Exception
Clear all bound parameters of the compiled SQLite3 statement.

Throws:
Exception

close

public void close()
           throws Exception
Close the compiled SQLite3 statement.

Throws:
Exception

column_bytes

public byte[] column_bytes(int col)
                    throws Exception
Retrieve blob column from exec'ed SQLite3 statement.

Parameters:
col - column number, 0-based
Returns:
byte[] column value
Throws:
Exception

column_count

public int column_count()
                 throws Exception
Retrieve number of columns of exec'ed SQLite3 statement.

Returns:
int number of columns
Throws:
Exception

column_database_name

public java.lang.String column_database_name(int col)
                                      throws Exception
Return database name of column of SQLite3 statement.

Parameters:
col - column number, 0-based
Returns:
String or null
Throws:
Exception

column_decltype

public java.lang.String column_decltype(int col)
                                 throws Exception
Return declared column type of SQLite3 statement.

Parameters:
col - column number, 0-based
Returns:
String or null
Throws:
Exception

column_double

public double column_double(int col)
                     throws Exception
Retrieve double column from exec'ed SQLite3 statement.

Parameters:
col - column number, 0-based
Returns:
double column value
Throws:
Exception

column_int

public int column_int(int col)
               throws Exception
Retrieve integer column from exec'ed SQLite3 statement.

Parameters:
col - column number, 0-based
Returns:
int column value
Throws:
Exception

column_long

public long column_long(int col)
                 throws Exception
Retrieve long column from exec'ed SQLite3 statement.

Parameters:
col - column number, 0-based
Returns:
long column value
Throws:
Exception

column_origin_name

public java.lang.String column_origin_name(int col)
                                    throws Exception
Return origin column name of column of SQLite3 statement.

Parameters:
col - column number, 0-based
Returns:
String or null
Throws:
Exception

column_string

public java.lang.String column_string(int col)
                               throws Exception
Retrieve string column from exec'ed SQLite3 statement.

Parameters:
col - column number, 0-based
Returns:
String column value
Throws:
Exception

column_table_name

public java.lang.String column_table_name(int col)
                                   throws Exception
Return table name of column of SQLite3 statement.

Parameters:
col - column number, 0-based
Returns:
String or null
Throws:
Exception

column_type

public int column_type(int col)
                throws Exception
Retrieve column type from exec'ed SQLite3 statement.

Parameters:
col - column number, 0-based
Returns:
column type code, e.g. SQLite.Constants.SQLITE_INTEGER
Throws:
Exception

column

public java.lang.Object column(int col)
                        throws Exception
Retrieve column data as object from exec'ed SQLite3 statement.

Parameters:
col - column number, 0-based
Returns:
Object or null
Throws:
Exception

finalize

protected void finalize()
Destructor for object.

Overrides:
finalize in class java.lang.Object

internal_init

private static void internal_init()
Internal native initializer.


prepare

public boolean prepare()
                throws Exception
Prepare the next SQL statement for the Stmt instance.

Returns:
true when the next piece of the SQL statement sequence has been prepared, false on end of statement sequence.
Throws:
Exception

reset

public void reset()
           throws Exception
Reset the compiled SQLite3 statement without clearing parameter bindings.

Throws:
Exception

status

public int status(int op,
                  boolean flg)
Return statement status information.

Parameters:
op - which counter to report
flg - reset flag
Returns:
counter

step

public boolean step()
             throws Exception
Perform one step of compiled SQLite3 statement. Example:
   ...
   try {
     Stmt s = db.prepare("select * from x; select * from y;");
     s.bind(...);
     ...
     s.bind(...);
     while (s.step(cb)) {
       Object o = s.value(...);
       ...
     }
     // s.reset() for re-execution or
     // s.prepare() for the next piece of SQL
     while (s.prepare()) {
       s.bind(...);
       ...
       s.bind(...);
       while (s.step(cb)) {
         Object o = s.value(...);
         ...
       }
     }
   } catch (SQLite.Exception e) {
     s.close();
   }
 

Returns:
true when row data is available, false on end of result set.
Throws:
Exception


Contact: Christian Werner