|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SQLite.Database
public class 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,
java.lang.String destName,
Database src,
java.lang.String srcName)
|
private void |
_busy_handler(BusyHandler bh)
|
private void |
_busy_timeout(int ms)
|
private long |
_changes()
|
private void |
_close()
|
private static boolean |
_complete(java.lang.String sql)
|
private void |
_create_aggregate(java.lang.String name,
int nargs,
Function f)
|
private void |
_create_function(java.lang.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 java.lang.String |
_errmsg()
|
private void |
_exec(java.lang.String sql,
Callback cb)
|
private void |
_exec(java.lang.String sql,
Callback cb,
java.lang.String[] args)
|
private void |
_finalize()
|
private void |
_function_type(java.lang.String name,
int type)
|
private void |
_interrupt()
|
private void |
_key(byte[] ekey)
|
private long |
_last_insert_rowid()
|
private void |
_open_aux_file(java.lang.String filename)
|
private void |
_open_blob(java.lang.String db,
java.lang.String table,
java.lang.String column,
long row,
boolean rw,
Blob blob)
Internal SQLite open blob method. |
private void |
_open(java.lang.String filename,
int mode)
|
private void |
_open4(java.lang.String filename,
int mode,
java.lang.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(java.lang.String enc)
|
private static int |
_status(int op,
int[] info,
boolean flag)
|
private void |
_trace(Trace tr)
|
Backup |
backup(Database dest,
java.lang.String destName,
java.lang.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(java.lang.String sql)
Compile and return SQLite VM for SQL statement. |
Vm |
compile(java.lang.String sql,
java.lang.String[] args)
Compile and return SQLite VM for SQL statement. |
static boolean |
complete(java.lang.String sql)
See if an SQL statement is complete. |
void |
create_aggregate(java.lang.String name,
int nargs,
Function f)
Create aggregate function. |
void |
create_function(java.lang.String name,
int nargs,
Function f)
Create regular function. |
int |
db_status(int op,
int[] info,
boolean flag)
Return information on SQLite connection status. |
java.lang.String |
dbversion()
Return SQLite version number as string. |
java.lang.String |
error_message()
Return last error message of SQLite3 engine. |
static java.lang.String |
error_string(int error_code)
Return error string given SQLite error code (SQLite2). |
void |
exec(java.lang.String sql,
Callback cb)
Execute an SQL statement and invoke callback methods for each row of the result set. |
void |
exec(java.lang.String sql,
Callback cb,
java.lang.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(java.lang.String name,
int type)
Set function return type. |
TableResult |
get_table(java.lang.String sql)
Convenience method to retrieve an entire result set into memory. |
TableResult |
get_table(java.lang.String sql,
int maxrows)
Convenience method to retrieve an entire result set into memory. |
TableResult |
get_table(java.lang.String sql,
int maxrows,
java.lang.String[] args)
Convenience method to retrieve an entire result set into memory. |
TableResult |
get_table(java.lang.String sql,
java.lang.String[] args)
Convenience method to retrieve an entire result set into memory. |
void |
get_table(java.lang.String sql,
java.lang.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(java.lang.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(java.lang.String s)
Make long value from julian date for java.lang.Date |
void |
open_aux_file(java.lang.String filename)
Open SQLite auxiliary database file for temporary tables. |
Blob |
open_blob(java.lang.String db,
java.lang.String table,
java.lang.String column,
long row,
boolean rw)
Open an SQLite3 blob. |
void |
open(java.lang.String filename,
int mode)
Open an SQLite database file. |
void |
open(java.lang.String filename,
int mode,
java.lang.String vfs)
Open an SQLite database file. |
void |
open(java.lang.String filename,
int mode,
java.lang.String vfs,
boolean ver2)
Open an SQLite database file. |
Stmt |
prepare(java.lang.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(java.lang.String skey)
Change the key of a encrypted database. |
void |
set_authorizer(Authorizer auth)
Set authorizer function. |
void |
set_encoding(java.lang.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(java.lang.String sql,
Stmt stmt)
Internal SQLite3 prepare method. |
void |
trace(Trace tr)
Set trace function. |
static java.lang.String |
version()
Return SQLite version number as string. |
private void |
vm_compile_args(java.lang.String sql,
Vm vm,
java.lang.String[] args)
Internal compile method, SQLite 3.0 only. |
private void |
vm_compile(java.lang.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, java.lang.String destName, Database src, java.lang.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(java.lang.String sql)
private void _create_aggregate(java.lang.String name, int nargs, Function f)
private void _create_function(java.lang.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 java.lang.String _errmsg()
private void _exec(java.lang.String sql, Callback cb) throws Exception
Exception
private void _exec(java.lang.String sql, Callback cb, java.lang.String[] args) throws Exception
Exception
private void _finalize()
private void _function_type(java.lang.String name, int type)
private void _interrupt()
private void _key(byte[] ekey)
private long _last_insert_rowid()
private void _open_aux_file(java.lang.String filename) throws Exception
Exception
private void _open_blob(java.lang.String db, java.lang.String table, java.lang.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
private void _open(java.lang.String filename, int mode) throws Exception
Exception
private void _open4(java.lang.String filename, int mode, java.lang.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(java.lang.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, java.lang.String destName, java.lang.String srcName) throws Exception
dest
- destination databasedestName
- schema of destination database to be backed upsrcName
- schema of source database
Exception
public 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
public Vm compile(java.lang.String sql) throws Exception
sql
- SQL statement to be compiled
Exception
public Vm compile(java.lang.String sql, java.lang.String[] args) throws Exception
sql
- SQL statement to be compiledargs
- arguments for the SQL statement, '%q' substitution
Exception
public static boolean complete(java.lang.String sql)
sql
- the SQL statement to be checkedpublic void create_aggregate(java.lang.String name, int nargs, Function f)
name
- the name of the new functionnargs
- number of arguments to functionf
- interface of functionpublic void create_function(java.lang.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 java.lang.String dbversion()
public java.lang.String error_message()
public static java.lang.String error_string(int error_code)
error_code
- the error code
public void exec(java.lang.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
public void exec(java.lang.String sql, Callback cb, java.lang.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
protected void finalize()
finalize
in class java.lang.Object
public void function_type(java.lang.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(java.lang.String sql) throws Exception
sql
- the SQL statement to be executed
Exception
public TableResult get_table(java.lang.String sql, int maxrows) throws Exception
sql
- the SQL statement to be executedmaxrows
- the max. number of rows to retrieve
Exception
public TableResult get_table(java.lang.String sql, int maxrows, java.lang.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
public TableResult get_table(java.lang.String sql, java.lang.String[] args) throws Exception
sql
- the SQL statement to be executedargs
- arguments for the SQL statement, '%q' substitution
Exception
public void get_table(java.lang.String sql, java.lang.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
private 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
public void key(java.lang.String skey) throws Exception
skey
- the key as String
Exception
public 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(java.lang.String s) throws Exception
s
- string (double value) (julian date in SQLite3 format)
Exception
public void open_aux_file(java.lang.String filename) throws Exception
filename
- the name of the auxiliary file or null
Exception
public Blob open_blob(java.lang.String db, java.lang.String table, java.lang.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
public void open(java.lang.String filename, int mode) throws Exception
filename
- the name of the database filemode
- open mode (e.g. SQLITE_OPEN_READONLY)
Exception
public void open(java.lang.String filename, int mode, java.lang.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
public void open(java.lang.String filename, int mode, java.lang.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
public Stmt prepare(java.lang.String sql) throws Exception
sql
- SQL statement to be prepared
Exception
public 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
public void rekey(java.lang.String skey) throws Exception
skey
- the key as String
Exception
public void set_authorizer(Authorizer auth)
auth
- the authorizer functionpublic void set_encoding(java.lang.String enc) throws Exception
enc
- name of encoding
Exception
protected 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(java.lang.String sql, Stmt stmt) throws Exception
sql
- SQL statementstmt
- Stmt object
Exception
public void trace(Trace tr)
tr
- the trace functionpublic static java.lang.String version()
private void vm_compile_args(java.lang.String sql, Vm vm, java.lang.String[] args) throws Exception
sql
- SQL statementargs
- arguments for the SQL statement, '%q' substitutionvm
- Vm object
Exception
private void vm_compile(java.lang.String sql, Vm vm) throws Exception
sql
- SQL statementvm
- Vm object
Exception
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |