SQLite
public class Database extends Object
Field Summary | |
---|---|
protected int | error_code
Internal last error code for exec() methods. |
protected long | handle
Internal handle for the native SQLite API. |
Method Summary | |
---|---|
void | busy_handler(BusyHandler bh)
Establish a busy callback method which gets called when
an SQLite table is locked.
|
void | busy_timeout(int ms)
Set the timeout for waiting for an SQLite table to become
unlocked.
|
long | changes()
Return the number of changed rows for the last statement. |
void | close()
Close the underlying SQLite database file. |
Vm | compile(String sql)
Compile and return SQLite VM for SQL statement. |
Vm | compile(String sql, String[] args)
Compile and return SQLite VM for SQL statement. |
static boolean | complete(String sql)
See if an SQL statement is complete.
|
void | create_aggregate(String name, int nargs, Function f)
Create aggregate function.
|
void | create_function(String name, int nargs, Function f)
Create regular function.
|
String | dbversion()
Return SQLite version number as string.
|
String | error_message()
Return last error message of SQLite3 engine.
|
static String | error_string(int error_code)
Return error string given SQLite error code (SQLite2).
|
void | exec(String sql, Callback cb)
Execute an SQL statement and invoke callback methods
for each row of the result set. It the method fails, an SQLite.Exception is thrown and an error code is set, which later can be retrieved by the last_error() method. |
void | exec(String sql, Callback cb, String[] args)
Execute an SQL statement and invoke callback methods
for each row of the result set. |
protected void | finalize()
Destructor for object. |
void | function_type(String name, int type)
Set function return type. |
TableResult | get_table(String sql)
Convenience method to retrieve an entire result
set into memory.
|
TableResult | get_table(String sql, String[] args)
Convenience method to retrieve an entire result
set into memory.
|
void | get_table(String sql, String[] args, TableResult tbl)
Convenience method to retrieve an entire result
set into memory.
|
static void | internal_init()
Internal native initializer. |
void | interrupt()
Abort the current SQLite operation. |
boolean | is3()
Check type of open database. |
static double | julian_from_long(long ms)
Make julian date value from java.lang.Date
|
void | key(byte[] ekey)
Specify key for encrypted database. |
void | key(String skey)
Specify key for encrypted database. |
int | last_error()
Return the code of the last error occured in
any of the exec() methods. |
long | last_insert_rowid()
Return the row identifier of the last inserted
row. |
static long | long_from_julian(double d)
Make long value from julian date for java.lang.Date
|
static long | long_from_julian(String s)
Make long value from julian date for java.lang.Date
|
void | open(String filename, int mode)
Open an SQLite database file.
|
void | open_aux_file(String filename)
Open SQLite auxiliary database file for temporary
tables.
|
Blob | open_blob(String db, String table, String column, long row, boolean rw)
Open an SQLite3 blob. |
Stmt | prepare(String sql)
Prepare and return SQLite3 statement for SQL. |
void | progress_handler(int n, ProgressHandler p)
Establish a progress callback method which gets called after
N SQLite VM opcodes.
|
void | rekey(byte[] ekey)
Change the key of a encrypted database. |
void | rekey(String skey)
Change the key of a encrypted database. |
void | set_authorizer(Authorizer auth)
Set authorizer function. |
void | set_encoding(String enc)
Set character encoding. |
protected void | set_last_error(int error_code)
Internal: set error code. |
void | stmt_prepare(String sql, Stmt stmt)
Internal SQLite3 prepare method. |
void | trace(Trace tr)
Set trace function. |
static String | version()
Return SQLite version number as string.
|
void | vm_compile(String sql, Vm vm)
Internal compile method. |
void | vm_compile_args(String sql, Vm vm, String[] args)
Internal compile method, SQLite 3.0 only. |
void | _busy_handler(BusyHandler bh) |
void | _busy_timeout(int ms) |
long | _changes() |
void | _close() |
static boolean | _complete(String sql) |
void | _create_aggregate(String name, int nargs, Function f) |
void | _create_function(String name, int nargs, Function f) |
String | _errmsg() |
void | _exec(String sql, Callback cb) |
void | _exec(String sql, Callback cb, String[] args) |
void | _finalize() |
void | _function_type(String name, int type) |
void | _interrupt() |
void | _key(byte[] ekey) |
long | _last_insert_rowid() |
void | _open(String filename, int mode) |
void | _open_aux_file(String filename) |
void | _open_blob(String db, String table, String column, long row, boolean rw, Blob blob)
Internal SQLite open blob method. |
void | _progress_handler(int n, ProgressHandler p) |
void | _rekey(byte[] ekey) |
void | _set_authorizer(Authorizer auth) |
void | _set_encoding(String enc) |
void | _trace(Trace tr) |
Parameters: bh the object implementing the busy callback method
Parameters: ms number of millisecond to wait
Parameters: sql SQL statement to be compiled
Returns: a Vm object
Parameters: sql SQL statement to be compiled args arguments for the SQL statement, '%q' substitution
Returns: a Vm object
Parameters: sql the SQL statement to be checked
Parameters: name the name of the new function nargs number of arguments to function f interface of function
Parameters: name the name of the new function nargs number of arguments to function f interface of function
Returns: error string or null
Parameters: error_code the error code
Returns: error string
It the method fails, an SQLite.Exception is thrown and an error code is set, which later can be retrieved by the last_error() method.
Parameters: sql the SQL statement to be executed cb the object implementing the callback methods
String args[] = new String[1]; args[0] = "tab%"; db.exec("select * from sqlite_master where type like '%q'", null, args);It the method fails, an SQLite.Exception is thrown and an error code is set, which later can be retrieved by the last_error() method.
Parameters: sql the SQL statement to be executed cb the object implementing the callback methods args arguments for the SQL statement, '%q' substitution
Parameters: name the name of the function whose return type is to be set type return type code, e.g. SQLite.Constants.SQLITE_NUMERIC
Parameters: sql the SQL statement to be executed
Returns: result set
Parameters: sql the SQL statement to be executed args arguments for the SQL statement, '%q' substitution
Returns: result set
Parameters: sql the SQL statement to be executed args arguments for the SQL statement, '%q' substitution tbl TableResult to receive result set
Returns: result set
Returns: true if SQLite3 database
Parameters: ms millisecond value of java.lang.Date
Returns: double
Parameters: ekey the key as byte array
Parameters: skey the key as String
Returns: SQLite error code
Parameters: d double value (julian date in SQLite3 format)
Returns: long
Parameters: s string (double value) (julian date in SQLite3 format)
Returns: long
Parameters: filename the name of the database file mode open mode, currently ignored
Parameters: filename the name of the auxiliary file or null
Parameters: db database name table table name column column name row row identifier rw if true, open for read-write, else read-only
Returns: a Blob object
Parameters: sql SQL statement to be prepared
Returns: a Stmt object
Parameters: n number of SQLite VM opcodes until callback is invoked p the object implementing the progress callback method
Parameters: ekey the key as byte array
Parameters: skey the key as String
Parameters: auth the authorizer function
Parameters: enc name of encoding
Parameters: error_code new error code
Parameters: sql SQL statement stmt Stmt object
Parameters: tr the trace function
Parameters: sql SQL statement vm Vm object
Parameters: sql SQL statement args arguments for the SQL statement, '%q' substitution vm Vm object
Parameters: db database name table table name column column name row row identifier rw if true, open for read-write, else read-only blob Blob object