Package SQLite
Class Stmt
java.lang.Object
SQLite.Stmt
public class Stmt extends 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
Fields Modifier and Type Field Description protected interror_codeInternal last error code for prepare()/step() methods. -
Constructor Summary
Constructors Constructor Description Stmt() -
Method Summary
Modifier and Type Method Description voidbind(int pos)Bind positional SQL null to compiled SQLite3 statement.voidbind(int pos, byte[] value)Bind positional byte array to compiled SQLite3 statement.voidbind(int pos, double value)Bind positional double value to compiled SQLite3 statement.voidbind(int pos, int value)Bind positional integer value to compiled SQLite3 statement.voidbind(int pos, long value)Bind positional long value to compiled SQLite3 statement.voidbind(int pos, String value)Bind positional String to compiled SQLite3 statement.intbind_parameter_count()Return number of parameters in compiled SQLite3 statement.intbind_parameter_index(String name)Return index of named parameter in compiled SQLite3 statement.Stringbind_parameter_name(int pos)Return name of parameter in compiled SQLite3 statement.voidbind_zeroblob(int pos, int length)Bind positional zero'ed blob to compiled SQLite3 statement.voidclear_bindings()Clear all bound parameters of the compiled SQLite3 statement.voidclose()Close the compiled SQLite3 statement.Objectcolumn(int col)Retrieve column data as object from exec'ed SQLite3 statement.byte[]column_bytes(int col)Retrieve blob column from exec'ed SQLite3 statement.intcolumn_count()Retrieve number of columns of exec'ed SQLite3 statement.Stringcolumn_database_name(int col)Return database name of column of SQLite3 statement.Stringcolumn_decltype(int col)Return declared column type of SQLite3 statement.doublecolumn_double(int col)Retrieve double column from exec'ed SQLite3 statement.intcolumn_int(int col)Retrieve integer column from exec'ed SQLite3 statement.longcolumn_long(int col)Retrieve long column from exec'ed SQLite3 statement.Stringcolumn_origin_name(int col)Return origin column name of column of SQLite3 statement.Stringcolumn_string(int col)Retrieve string column from exec'ed SQLite3 statement.Stringcolumn_table_name(int col)Return table name of column of SQLite3 statement.intcolumn_type(int col)Retrieve column type from exec'ed SQLite3 statement.protected voidfinalize()Destructor for object.booleanprepare()Prepare the next SQL statement for the Stmt instance.voidreset()Reset the compiled SQLite3 statement without clearing parameter bindings.intstatus(int op, boolean flg)Return statement status information.booleanstep()Perform one step of compiled SQLite3 statement.
-
Field Details
-
error_code
protected int error_codeInternal last error code for prepare()/step() methods.
-
-
Constructor Details
-
Stmt
public Stmt()
-
-
Method Details
-
prepare
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
-
step
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
-
close
Close the compiled SQLite3 statement.- Throws:
Exception
-
reset
Reset the compiled SQLite3 statement without clearing parameter bindings.- Throws:
Exception
-
clear_bindings
Clear all bound parameters of the compiled SQLite3 statement.- Throws:
Exception
-
bind
Bind positional integer value to compiled SQLite3 statement.- Parameters:
pos- parameter index, 1-basedvalue- value of parameter- Throws:
Exception
-
bind
Bind positional long value to compiled SQLite3 statement.- Parameters:
pos- parameter index, 1-basedvalue- value of parameter- Throws:
Exception
-
bind
Bind positional double value to compiled SQLite3 statement.- Parameters:
pos- parameter index, 1-basedvalue- value of parameter- Throws:
Exception
-
bind
Bind positional byte array to compiled SQLite3 statement.- Parameters:
pos- parameter index, 1-basedvalue- value of parameter, may be null- Throws:
Exception
-
bind
Bind positional String to compiled SQLite3 statement.- Parameters:
pos- parameter index, 1-basedvalue- value of parameter, may be null- Throws:
Exception
-
bind
Bind positional SQL null to compiled SQLite3 statement.- Parameters:
pos- parameter index, 1-based- Throws:
Exception
-
bind_zeroblob
Bind positional zero'ed blob to compiled SQLite3 statement.- Parameters:
pos- parameter index, 1-basedlength- byte size of zero blob- Throws:
Exception
-
bind_parameter_count
Return number of parameters in compiled SQLite3 statement.- Returns:
- int number of parameters
- Throws:
Exception
-
bind_parameter_name
Return name of parameter in compiled SQLite3 statement.- Parameters:
pos- parameter index, 1-based- Returns:
- String parameter name
- Throws:
Exception
-
bind_parameter_index
Return index of named parameter in compiled SQLite3 statement.- Parameters:
name- of parameter- Returns:
- int index of parameter, 1-based
- Throws:
Exception
-
column_int
Retrieve integer column from exec'ed SQLite3 statement.- Parameters:
col- column number, 0-based- Returns:
- int column value
- Throws:
Exception
-
column_long
Retrieve long column from exec'ed SQLite3 statement.- Parameters:
col- column number, 0-based- Returns:
- long column value
- Throws:
Exception
-
column_double
Retrieve double column from exec'ed SQLite3 statement.- Parameters:
col- column number, 0-based- Returns:
- double column value
- Throws:
Exception
-
column_bytes
Retrieve blob column from exec'ed SQLite3 statement.- Parameters:
col- column number, 0-based- Returns:
- byte[] column value
- Throws:
Exception
-
column_string
Retrieve string column from exec'ed SQLite3 statement.- Parameters:
col- column number, 0-based- Returns:
- String column value
- Throws:
Exception
-
column_type
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_count
Retrieve number of columns of exec'ed SQLite3 statement.- Returns:
- int number of columns
- Throws:
Exception
-
column
Retrieve column data as object from exec'ed SQLite3 statement.- Parameters:
col- column number, 0-based- Returns:
- Object or null
- Throws:
Exception
-
column_table_name
Return table name of column of SQLite3 statement.- Parameters:
col- column number, 0-based- Returns:
- String or null
- Throws:
Exception
-
column_database_name
Return database name of column of SQLite3 statement.- Parameters:
col- column number, 0-based- Returns:
- String or null
- Throws:
Exception
-
column_decltype
Return declared column type of SQLite3 statement.- Parameters:
col- column number, 0-based- Returns:
- String or null
- Throws:
Exception
-
column_origin_name
Return origin column name of column of SQLite3 statement.- Parameters:
col- column number, 0-based- Returns:
- String or null
- Throws:
Exception
-
status
public int status(int op, boolean flg)Return statement status information.- Parameters:
op- which counter to reportflg- reset flag- Returns:
- counter
-
finalize
protected void finalize()Destructor for object.
-