Package org.sqlite.core
Class DB
java.lang.Object
org.sqlite.core.DB
- All Implemented Interfaces:
Codes
- Direct Known Subclasses:
NativeDB
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from interface org.sqlite.core.Codes
SQLITE_ABORT, SQLITE_AUTH, SQLITE_BLOB, SQLITE_BUSY, SQLITE_CANTOPEN, SQLITE_CONSTRAINT, SQLITE_CORRUPT, SQLITE_DONE, SQLITE_EMPTY, SQLITE_ERROR, SQLITE_FLOAT, SQLITE_FULL, SQLITE_INTEGER, SQLITE_INTERNAL, SQLITE_INTERRUPT, SQLITE_IOERR, SQLITE_LOCKED, SQLITE_MISMATCH, SQLITE_MISUSE, SQLITE_NOLFS, SQLITE_NOMEM, SQLITE_NOTFOUND, SQLITE_NULL, SQLITE_OK, SQLITE_PERM, SQLITE_PROTOCOL, SQLITE_READONLY, SQLITE_ROW, SQLITE_SCHEMA, SQLITE_TEXT, SQLITE_TOOBIG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void_close()Closes the SQLite interface to a database.abstract intComplies, evaluates, executes and commits an SQL statement.protected abstract voidCreates an SQLite interface to a database with the provided open flags.voidaddCommitListener(SQLiteCommitListener listener) voidaddUpdateListener(SQLiteUpdateListener listener) abstract intbackup(String dbName, String destFileName, DB.ProgressObserver observer) abstract intbackup(String dbName, String destFileName, DB.ProgressObserver observer, int sleepTimeMillis, int nTimeouts, int pagesPerStep) abstract voidbusy_handler(BusyHandler busyHandler) Sets a busy handler that sleeps for a specified amount of time when a table is locked.abstract voidbusy_timeout(int ms) Sets a busy handler that sleeps for a specified amount of time when a table is locked.abstract longchanges()abstract intclear_bindings(long stmt) Reset all bindings on a prepared statement (reset all host parameters to NULL).abstract voidfinal voidclose()Closes a database connection and finalizes any remaining statements before the closing operation.abstract byte[]column_blob(long stmt, int col) abstract intcolumn_count(long stmt) abstract Stringcolumn_decltype(long stmt, int col) abstract doublecolumn_double(long stmt, int col) abstract intcolumn_int(long stmt, int col) abstract longcolumn_long(long stmt, int col) abstract Stringcolumn_name(long stmt, int col) final String[]column_names(long stmt) Returns an array of column names in the result set of the SELECT statement.abstract Stringcolumn_table_name(long stmt, int col) abstract Stringcolumn_text(long stmt, int col) abstract intcolumn_type(long stmt, int col) abstract intcreate_collation(String name, Collation c) Create a user defined collation with given collation name and the collation object.abstract intcreate_function(String name, Function f, int nArgs, int flags) Create a user defined function with given function name and the function object.abstract voiddeserialize(String schema, byte[] buff) abstract intdestroy_collation(String name) Create a user defined collation with given collation name and the collation object.abstract intdestroy_function(String name) De-registers a user defined functionabstract intenable_load_extension(boolean enable) Enables or disables loading of SQLite extensions.final voidExecutes an SQL statement using the process of compiling, evaluating, and destroying the prepared statement object.final booleanexecute(CoreStatement stmt, Object[] vals) final longexecuteUpdate(CoreStatement stmt, Object[] vals) Execute an SQL INSERT, UPDATE or DELETE statement with the Stmt object and an array of parameter values of the SQL statement..protected abstract intfinalize(long stmt) Destroys a prepared statement.intfinalize(SafeStmtPtr safePtr, long ptr) Destroys a statement.getUrl()abstract voidAborts any pending operation and returns at its earliest opportunity.booleanisClosed()abstract StringReturns the value for SQLITE_VERSION, SQLITE_VERSION_NUMBER, and SQLITE_SOURCE_ID C preprocessor macros that are associated with the library.abstract intlimit(int id, int value) static SQLiteExceptionnewSQLException(int errorCode, String errorMessage) Throws formatted SQLException with error code and message.final voidCreates an SQLite interface to a database for the given connection.protected abstract SafeStmtPtrComplies an SQL statement.final voidprepare(CoreStatement stmt) Complies the an SQL statement.abstract voidregister_progress_handler(int vmCalls, ProgressHandler progressHandler) Progress handlervoidremoveCommitListener(SQLiteCommitListener listener) voidremoveUpdateListener(SQLiteUpdateListener listener) abstract intreset(long stmt) Sets a prepared statement object back to its initial state, ready to be re-executed.abstract intrestore(String dbName, String sourceFileName, DB.ProgressObserver observer) abstract intrestore(String dbName, String sourceFileName, DB.ProgressObserver observer, int sleepTimeMillis, int nTimeouts, int pagesPerStep) abstract voidresult_blob(long context, byte[] val) Sets the result of an SQL function as blob data type with the pointer to the SQLite database context and the the result value of byte array.abstract voidresult_double(long context, double val) Sets the result of an SQL function as double data type with the pointer to the SQLite database context and the the result value of double.abstract voidresult_error(long context, String err) Sets the result of an SQL function as an error with the pointer to the SQLite database context and the the error of String.abstract voidresult_int(long context, int val) Sets the result of an SQL function as int data type with the pointer to the SQLite database context and the the result value of int.abstract voidresult_long(long context, long val) Sets the result of an SQL function as long data type with the pointer to the SQLite database context and the the result value of long.abstract voidresult_null(long context) Sets the result of an SQL function as NULL with the pointer to the SQLite database context.abstract voidresult_text(long context, String val) Sets the result of an SQL function as text data type with the pointer to the SQLite database context and the the result value of String.abstract byte[]abstract intshared_cache(boolean enable) Enables or disables the sharing of the database cache and schema data structures between connections to the same database.abstract intstep(long stmt) Evaluates a statement.final voidthrowex(int errorCode) Throws SQLException with error code.abstract longabstract byte[]value_blob(Function f, int arg) abstract doublevalue_double(Function f, int arg) abstract intAccesses the parameter values on the function or aggregate in int data type with the function object and the parameter value.abstract longvalue_long(Function f, int arg) abstract Stringvalue_text(Function f, int arg) abstract intvalue_type(Function f, int arg)
-
Constructor Details
-
DB
- Throws:
SQLException
-
-
Method Details
-
getUrl
-
isClosed
public boolean isClosed() -
getConfig
-
interrupt
Aborts any pending operation and returns at its earliest opportunity.- Throws:
SQLException- See Also:
-
busy_timeout
Sets a busy handler that sleeps for a specified amount of time when a table is locked.- Parameters:
ms- Time to sleep in milliseconds.- Throws:
SQLException- See Also:
-
busy_handler
Sets a busy handler that sleeps for a specified amount of time when a table is locked.- Parameters:
busyHandler-- Throws:
SQLException- See Also:
-
libversion
Returns the value for SQLITE_VERSION, SQLITE_VERSION_NUMBER, and SQLITE_SOURCE_ID C preprocessor macros that are associated with the library.- Returns:
- Compile-time SQLite version information.
- Throws:
SQLException- See Also:
-
changes
- Returns:
- Number of rows that were changed, inserted or deleted by the last SQL statement
- Throws:
SQLException- See Also:
-
total_changes
- Returns:
- Number of row changes caused by INSERT, UPDATE or DELETE statements since the database connection was opened.
- Throws:
SQLException- See Also:
-
enable_load_extension
Enables or disables loading of SQLite extensions.- Parameters:
enable- True to enable; false otherwise.- Returns:
- Result Codes
- Throws:
SQLException- See Also:
-
exec
Executes an SQL statement using the process of compiling, evaluating, and destroying the prepared statement object.- Parameters:
sql- SQL statement to be executed.- Throws:
SQLException- See Also:
-
open
Creates an SQLite interface to a database for the given connection.- Parameters:
file- The database.openFlags- File opening configurations (https://www.sqlite.org/c3ref/c_open_autoproxy.html)- Throws:
SQLException- See Also:
-
close
Closes a database connection and finalizes any remaining statements before the closing operation.- Throws:
SQLException- See Also:
-
prepare
Complies the an SQL statement.- Parameters:
stmt- The SQL statement to compile.- Throws:
SQLException- See Also:
-
finalize
Destroys a statement.- Parameters:
safePtr- the pointer wrapper to remove from internal structuresptr- the raw pointer to free- Returns:
- Result Codes
- Throws:
SQLException- if finalization fails- See Also:
-
_open
Creates an SQLite interface to a database with the provided open flags.- Parameters:
filename- The database to open.openFlags- File opening configurations (https://www.sqlite.org/c3ref/c_open_autoproxy.html)- Throws:
SQLException- See Also:
-
_close
Closes the SQLite interface to a database.- Throws:
SQLException- See Also:
-
_exec
Complies, evaluates, executes and commits an SQL statement.- Parameters:
sql- An SQL statement.- Returns:
- Result Codes
- Throws:
SQLException- See Also:
-
prepare
Complies an SQL statement.- Parameters:
sql- An SQL statement.- Returns:
- Result Codes
- Throws:
SQLException- See Also:
-
finalize
Destroys a prepared statement.- Parameters:
stmt- Pointer to the statement pointer.- Returns:
- Result Codes
- Throws:
SQLException- See Also:
-
step
Evaluates a statement.- Parameters:
stmt- Pointer to the statement.- Returns:
- Result Codes
- Throws:
SQLException- See Also:
-
reset
Sets a prepared statement object back to its initial state, ready to be re-executed.- Parameters:
stmt- Pointer to the statement.- Returns:
- Result Codes
- Throws:
SQLException- See Also:
-
clear_bindings
Reset all bindings on a prepared statement (reset all host parameters to NULL).- Parameters:
stmt- Pointer to the statement.- Returns:
- Result Codes
- Throws:
SQLException- See Also:
-
column_count
- Parameters:
stmt- Pointer to the statement.- Returns:
- Number of columns in the result set returned by the prepared statement.
- Throws:
SQLException- See Also:
-
column_type
- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- Datatype code for the initial data type of the result column.
- Throws:
SQLException- See Also:
-
column_decltype
- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- Declared type of the table column for prepared statement.
- Throws:
SQLException- See Also:
-
column_table_name
- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- Original text of column name which is the declared in the CREATE TABLE statement.
- Throws:
SQLException- See Also:
-
column_name
- Parameters:
stmt- Pointer to the statement.col- The number of column.- Returns:
- Name assigned to a particular column in the result set of a SELECT statement.
- Throws:
SQLException- See Also:
-
column_text
- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- Value of the column as text data type in the result set of a SELECT statement.
- Throws:
SQLException- See Also:
-
column_blob
- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- BLOB value of the column in the result set of a SELECT statement
- Throws:
SQLException- See Also:
-
column_double
- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- DOUBLE value of the column in the result set of a SELECT statement
- Throws:
SQLException- See Also:
-
column_long
- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- LONG value of the column in the result set of a SELECT statement.
- Throws:
SQLException- See Also:
-
column_int
- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- INT value of column in the result set of a SELECT statement.
- Throws:
SQLException- See Also:
-
result_null
Sets the result of an SQL function as NULL with the pointer to the SQLite database context.- Parameters:
context- Pointer to the SQLite database context.- Throws:
SQLException- See Also:
-
result_text
Sets the result of an SQL function as text data type with the pointer to the SQLite database context and the the result value of String.- Parameters:
context- Pointer to the SQLite database context.val- Result value of an SQL function.- Throws:
SQLException- See Also:
-
result_blob
Sets the result of an SQL function as blob data type with the pointer to the SQLite database context and the the result value of byte array.- Parameters:
context- Pointer to the SQLite database context.val- Result value of an SQL function.- Throws:
SQLException- See Also:
-
result_double
Sets the result of an SQL function as double data type with the pointer to the SQLite database context and the the result value of double.- Parameters:
context- Pointer to the SQLite database context.val- Result value of an SQL function.- Throws:
SQLException- See Also:
-
result_long
Sets the result of an SQL function as long data type with the pointer to the SQLite database context and the the result value of long.- Parameters:
context- Pointer to the SQLite database context.val- Result value of an SQL function.- Throws:
SQLException- See Also:
-
result_int
Sets the result of an SQL function as int data type with the pointer to the SQLite database context and the the result value of int.- Parameters:
context- Pointer to the SQLite database context.val- Result value of an SQL function.- Throws:
SQLException- See Also:
-
result_error
Sets the result of an SQL function as an error with the pointer to the SQLite database context and the the error of String.- Parameters:
context- Pointer to the SQLite database context.err- Error result of an SQL function.- Throws:
SQLException- See Also:
-
value_text
- Parameters:
f- SQLite function object.arg- Pointer to the parameter of the SQLite function or aggregate.- Returns:
- Parameter value of the given SQLite function or aggregate in text data type.
- Throws:
SQLException- See Also:
-
value_blob
- Parameters:
f- SQLite function object.arg- Pointer to the parameter of the SQLite function or aggregate.- Returns:
- Parameter value of the given SQLite function or aggregate in blob data type.
- Throws:
SQLException- See Also:
-
value_double
- Parameters:
f- SQLite function object.arg- Pointer to the parameter of the SQLite function or aggregate.- Returns:
- Parameter value of the given SQLite function or aggregate in double data type
- Throws:
SQLException- See Also:
-
value_long
- Parameters:
f- SQLite function object.arg- Pointer to the parameter of the SQLite function or aggregate.- Returns:
- Parameter value of the given SQLite function or aggregate in long data type.
- Throws:
SQLException- See Also:
-
value_int
Accesses the parameter values on the function or aggregate in int data type with the function object and the parameter value.- Parameters:
f- SQLite function object.arg- Pointer to the parameter of the SQLite function or aggregate.- Returns:
- Parameter value of the given SQLite function or aggregate.
- Throws:
SQLException- See Also:
-
value_type
- Parameters:
f- SQLite function object.arg- Pointer to the parameter of the SQLite function or aggregate.- Returns:
- Parameter datatype of the function or aggregate in int data type.
- Throws:
SQLException- See Also:
-
create_function
public abstract int create_function(String name, Function f, int nArgs, int flags) throws SQLException Create a user defined function with given function name and the function object.- Parameters:
name- The function name to be created.f- SQLite function object.flags- Extra flags to use when creating the function, such asFunction.FLAG_DETERMINISTIC- Returns:
- Result Codes
- Throws:
SQLException- See Also:
-
destroy_function
De-registers a user defined function- Parameters:
name- Name of the function to de-registered.- Returns:
- Result Codes
- Throws:
SQLException
-
create_collation
Create a user defined collation with given collation name and the collation object.- Parameters:
name- The collation name to be created.c- SQLite collation object.- Returns:
- Result Codes
- Throws:
SQLException- See Also:
-
destroy_collation
Create a user defined collation with given collation name and the collation object.- Parameters:
name- The collation name to be created.- Returns:
- Result Codes
- Throws:
SQLException
-
backup
public abstract int backup(String dbName, String destFileName, DB.ProgressObserver observer) throws SQLException - Parameters:
dbName- Database name to be backed up.destFileName- Target backup file name.observer- ProgressObserver object.- Returns:
- Result Codes
- Throws:
SQLException
-
backup
public abstract int backup(String dbName, String destFileName, DB.ProgressObserver observer, int sleepTimeMillis, int nTimeouts, int pagesPerStep) throws SQLException - Parameters:
dbName- Database name to be backed up.destFileName- Target backup file name.observer- ProgressObserver object.sleepTimeMillis- time to wait during a backup/restore operation if sqlite3_backup_step returns SQLITE_BUSY before continuingnTimeouts- the number of times sqlite3_backup_step can return SQLITE_BUSY before failingpagesPerStep- the number of pages to copy in each sqlite3_backup_step. If this is negative, the entire DB is copied at once.- Returns:
- Result Codes
- Throws:
SQLException
-
restore
public abstract int restore(String dbName, String sourceFileName, DB.ProgressObserver observer) throws SQLException - Parameters:
dbName- Database name for restoring data.sourceFileName- Source file name.observer- ProgressObserver object.- Returns:
- Result Codes
- Throws:
SQLException
-
restore
public abstract int restore(String dbName, String sourceFileName, DB.ProgressObserver observer, int sleepTimeMillis, int nTimeouts, int pagesPerStep) throws SQLException - Parameters:
dbName- the name of the db to restoresourceFileName- the filename of the source db to restoreobserver- ProgressObserver object.sleepTimeMillis- time to wait during a backup/restore operation if sqlite3_backup_step returns SQLITE_BUSY before continuingnTimeouts- the number of times sqlite3_backup_step can return SQLITE_BUSY before failingpagesPerStep- the number of pages to copy in each sqlite3_backup_step. If this is negative, the entire DB is copied at once.- Returns:
- Result Codes
- Throws:
SQLException
-
limit
- Parameters:
id- The id of the limit.value- The new value of the limit.- Returns:
- The prior value of the limit
- Throws:
SQLException- See Also:
-
register_progress_handler
public abstract void register_progress_handler(int vmCalls, ProgressHandler progressHandler) throws SQLException Progress handler- Throws:
SQLException
-
clear_progress_handler
- Throws:
SQLException
-
column_names
Returns an array of column names in the result set of the SELECT statement.- Parameters:
stmt- Stmt object.- Returns:
- String array of column names.
- Throws:
SQLException
-
execute
- Parameters:
stmt- Stmt object.vals- Array of parameter values.- Returns:
- True if a row of ResultSet is ready; false otherwise.
- Throws:
SQLException- See Also:
-
executeUpdate
Execute an SQL INSERT, UPDATE or DELETE statement with the Stmt object and an array of parameter values of the SQL statement..- Parameters:
stmt- Stmt object.vals- Array of parameter values.- Returns:
- Number of database rows that were changed or inserted or deleted by the most recently completed SQL.
- Throws:
SQLException
-
addUpdateListener
-
addCommitListener
-
removeUpdateListener
-
removeCommitListener
-
throwex
Throws SQLException with error code.- Parameters:
errorCode- Error code to be passed.- Throws:
SQLException- Formatted SQLException with error code.
-
newSQLException
Throws formatted SQLException with error code and message.- Parameters:
errorCode- Error code to be passed.errorMessage- Error message to be passed.- Returns:
- Formatted SQLException with error code and message.
-
serialize
- Throws:
SQLException
-
deserialize
- Throws:
SQLException
-