|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SQLite.Database
Main class wrapping an SQLite database.
Field Summary | |
protected int |
error_code
Internal last error code for exec() methods. |
protected long |
handle
Internal handle for the native SQLite API. |
Constructor Summary | |
Database()
|
Method Summary | |
private static void |
_backup(Backup b,
Database dest,
String destName,
Database src,
String srcName)
|
private void |
_busy_handler(BusyHandler bh)
|
private void |
_busy_timeout(int ms)
|
private long |
_changes()
|
private void |
_close()
|
private static boolean |
_complete(String sql)
|
private void |
_create_aggregate(String name,
int nargs,
Function f)
|
private void |
_create_function(String name,
int nargs,
Function f)
|
private int |
_db_status(int op,
int[] info,
boolean flag)
|
protected static boolean |
_enable_shared_cache(boolean onoff)
Enable/disable shared cache mode (SQLite 3.x only). |
private String |
_errmsg()
|
private void |
_exec(String sql,
Callback cb)
|
private void |
_exec(String sql,
Callback cb,
String[] args)
|
private void |
_finalize()
|
private void |
_function_type(String name,
int type)
|
private void |
_interrupt()
|
private void |
_key(byte[] ekey)
|
private long |
_last_insert_rowid()
|
private void |
_open_aux_file(String filename)
|
private void |
_open_blob(String db,
String table,
String column,
long row,
boolean rw,
Blob blob)
Internal SQLite open blob method. |
private void |
_open(String filename,
int mode)
|
private void |
_open4(String filename,
int mode,
String vfs,
boolean ver2)
|
private void |
_profile(Profile pr)
|
private void |
_progress_handler(int n,
ProgressHandler p)
|
private void |
_rekey(byte[] ekey)
|
private void |
_set_authorizer(Authorizer auth)
|
private void |
_set_encoding(String enc)
|
private static int |
_status(int op,
int[] info,
boolean flag)
|
private void |
_trace(Trace tr)
|
Backup |
backup(Database dest,
String destName,
String srcName)
Initiate a database backup, SQLite 3.x only. |
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. |
int |
db_status(int op,
int[] info,
boolean flag)
Return information on SQLite connection status. |
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. |
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,
int maxrows)
Convenience method to retrieve an entire result set into memory. |
TableResult |
get_table(String sql,
int maxrows,
String[] args)
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. |
private 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 occurred 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_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. |
void |
open(String filename,
int mode)
Open an SQLite database file. |
void |
open(String filename,
int mode,
String vfs)
Open an SQLite database file. |
void |
open(String filename,
int mode,
String vfs,
boolean ver2)
Open an SQLite database file. |
Stmt |
prepare(String sql)
Prepare and return SQLite3 statement for SQL. |
void |
profile(Profile pr)
Set profile function. |
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. |
static int |
status(int op,
int[] info,
boolean flag)
Return information on SQLite runtime status. |
private 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. |
private void |
vm_compile_args(String sql,
Vm vm,
String[] args)
Internal compile method, SQLite 3.0 only. |
private void |
vm_compile(String sql,
Vm vm)
Internal compile method. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int error_code
protected long handle
Constructor Detail |
public Database()
Method Detail |
private static void _backup(Backup b, Database dest, String destName, Database src, String srcName) throws Exception
Exception
private void _busy_handler(BusyHandler bh)
private void _busy_timeout(int ms)
private long _changes()
private void _close() throws Exception
Exception
private static boolean _complete(String sql)
private void _create_aggregate(String name, int nargs, Function f)
private void _create_function(String name, int nargs, Function f)
private int _db_status(int op, int[] info, boolean flag)
protected static boolean _enable_shared_cache(boolean onoff)
onoff
- boolean to enable or disable shared cache
private String _errmsg()
private void _exec(String sql, Callback cb) throws Exception
Exception
private void _exec(String sql, Callback cb, String[] args) throws Exception
Exception
private void _finalize()
private void _function_type(String name, int type)
private void _interrupt()
private void _key(byte[] ekey)
private long _last_insert_rowid()
private void _open_aux_file(String filename) throws Exception
Exception
private void _open_blob(String db, String table, String column, long row, boolean rw, Blob blob) throws Exception
db
- database nametable
- table namecolumn
- column namerow
- row identifierrw
- if true, open for read-write, else read-onlyblob
- Blob object
Exception
- indicating SQLite errorprivate void _open(String filename, int mode) throws Exception
Exception
private void _open4(String filename, int mode, String vfs, boolean ver2) throws Exception
Exception
private void _profile(Profile pr)
private void _progress_handler(int n, ProgressHandler p)
private void _rekey(byte[] ekey)
private void _set_authorizer(Authorizer auth)
private void _set_encoding(String enc) throws Exception
Exception
private static int _status(int op, int[] info, boolean flag)
private void _trace(Trace tr)
public Backup backup(Database dest, String destName, String srcName) throws Exception
dest
- destination databasedestName
- schema of destination database to be backed upsrcName
- schema of source database
Exception
- indicating SQLite errorpublic void busy_handler(BusyHandler bh)
bh
- the object implementing the busy callback methodpublic void busy_timeout(int ms)
ms
- number of millisecond to waitpublic long changes()
public void close() throws Exception
Exception
- indicating SQLite errorpublic Vm compile(String sql) throws Exception
sql
- SQL statement to be compiled
Exception
- indicating SQLite errorpublic Vm compile(String sql, String[] args) throws Exception
sql
- SQL statement to be compiledargs
- arguments for the SQL statement, '%q' substitution
Exception
- indicating SQLite errorpublic static boolean complete(String sql)
sql
- the SQL statement to be checked
public void create_aggregate(String name, int nargs, Function f)
name
- the name of the new functionnargs
- number of arguments to functionf
- interface of functionpublic void create_function(String name, int nargs, Function f)
name
- the name of the new functionnargs
- number of arguments to functionf
- interface of functionpublic int db_status(int op, int[] info, boolean flag)
op
- operation codeinfo
- output buffer, must be able to hold two
values (current/highwater)flag
- reset flag
public String dbversion()
public String error_message()
public static String error_string(int error_code)
error_code
- the error code
public void exec(String sql, Callback cb) throws Exception
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.
sql
- the SQL statement to be executedcb
- the object implementing the callback methods
Exception
- indicating SQLite errorpublic void exec(String sql, Callback cb, String[] args) throws Exception
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.
sql
- the SQL statement to be executedcb
- the object implementing the callback methodsargs
- arguments for the SQL statement, '%q' substitution
Exception
- indicating SQLite errorprotected void finalize()
public void function_type(String name, int type)
name
- the name of the function whose return type is to be settype
- return type code, e.g. SQLite.Constants.SQLITE_NUMERICpublic TableResult get_table(String sql) throws Exception
sql
- the SQL statement to be executed
Exception
- indicating SQLite errorpublic TableResult get_table(String sql, int maxrows) throws Exception
sql
- the SQL statement to be executedmaxrows
- the max. number of rows to retrieve
Exception
- indicating SQLite errorpublic TableResult get_table(String sql, int maxrows, String[] args) throws Exception
sql
- the SQL statement to be executedmaxrows
- the max. number of rows to retrieveargs
- arguments for the SQL statement, '%q' substitution
Exception
- indicating SQLite errorpublic TableResult get_table(String sql, String[] args) throws Exception
sql
- the SQL statement to be executedargs
- arguments for the SQL statement, '%q' substitution
Exception
- indicating SQLite errorpublic void get_table(String sql, String[] args, TableResult tbl) throws Exception
sql
- the SQL statement to be executedargs
- arguments for the SQL statement, '%q' substitutiontbl
- TableResult to receive result set
Exception
- indicating SQLite errorprivate static void internal_init()
public void interrupt()
public boolean is3()
public static double julian_from_long(long ms)
ms
- millisecond value of java.lang.Date
public void key(byte[] ekey) throws Exception
ekey
- the key as byte array
Exception
- indicating SQLite errorpublic void key(String skey) throws Exception
skey
- the key as String
Exception
- indicating SQLite errorpublic int last_error()
public long last_insert_rowid()
public static long long_from_julian(double d)
d
- double value (julian date in SQLite3 format)
public static long long_from_julian(String s) throws Exception
s
- string (double value) (julian date in SQLite3 format)
Exception
- indicating SQLite errorpublic void open_aux_file(String filename) throws Exception
filename
- the name of the auxiliary file or null
Exception
- indicating SQLite errorpublic Blob open_blob(String db, String table, String column, long row, boolean rw) throws Exception
db
- database nametable
- table namecolumn
- column namerow
- row identifierrw
- if true, open for read-write, else read-only
Exception
- indicating SQLite errorpublic void open(String filename, int mode) throws Exception
filename
- the name of the database filemode
- open mode (e.g. SQLITE_OPEN_READONLY)
Exception
- indicating SQLite errorpublic void open(String filename, int mode, String vfs) throws Exception
filename
- the name of the database filemode
- open mode (e.g. SQLITE_OPEN_READONLY)vfs
- VFS name (for SQLite ≥ 3.5)
Exception
- indicating SQLite errorpublic void open(String filename, int mode, String vfs, boolean ver2) throws Exception
filename
- the name of the database filemode
- open mode (e.g. SQLITE_OPEN_READONLY)vfs
- VFS name (for SQLite ≥ 3.5)ver2
- flag to force version on create (false = SQLite3, true = SQLite2)
Exception
- indicating SQLite errorpublic Stmt prepare(String sql) throws Exception
sql
- SQL statement to be prepared
Exception
- indicating SQLite errorpublic void profile(Profile pr)
pr
- the trace functionpublic void progress_handler(int n, ProgressHandler p)
n
- number of SQLite VM opcodes until callback is invokedp
- the object implementing the progress callback methodpublic void rekey(byte[] ekey) throws Exception
ekey
- the key as byte array
Exception
- indicating SQLite errorpublic void rekey(String skey) throws Exception
skey
- the key as String
Exception
- indicating SQLite errorpublic void set_authorizer(Authorizer auth)
auth
- the authorizer functionpublic void set_encoding(String enc) throws Exception
enc
- name of encoding
Exception
- indicating SQLite errorprotected void set_last_error(int error_code)
error_code
- new error codepublic static int status(int op, int[] info, boolean flag)
op
- operation codeinfo
- output buffer, must be able to hold two
values (current/highwater)flag
- reset flag
private void stmt_prepare(String sql, Stmt stmt) throws Exception
sql
- SQL statementstmt
- Stmt object
Exception
- indicating SQLite errorpublic void trace(Trace tr)
tr
- the trace functionpublic static String version()
private void vm_compile_args(String sql, Vm vm, String[] args) throws Exception
sql
- SQL statementargs
- arguments for the SQL statement, '%q' substitutionvm
- Vm object
Exception
- indicating SQLite errorprivate void vm_compile(String sql, Vm vm) throws Exception
sql
- SQL statementvm
- Vm object
Exception
- indicating SQLite error
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |