org.sqlite.core

## Class DB

- java.lang.Object
- - org.sqlite.core.DB

All Implemented Interfaces:
  Codes

Direct Known Subclasses:
  NativeDB

    public abstract class DB
    extends Object
    implements Codes

### Nested Class Summary

Nested Classes
`static interface` `DB.ProgressObserver`

### 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
Constructor and Description
`DB()`

### Method Summary

Methods
`protected abstract void` `_close()` Closes the SQLite interface to a database.
`abstract int` `_exec(String sql)` Complies, evaluates, executes and commits an SQL statement.
`protected abstract void` `_open(String filename, int openFlags)` Creates an SQLite interface to a database with the provided open flags.
`abstract int` `backup(String dbName, String destFileName, DB.ProgressObserver observer)`
`abstract void` `busy_timeout(int ms)` Sets a busy handler that sleeps for a specified amount of time when a table is locked.
`abstract int` `changes()`
`abstract int` `clear_bindings(long stmt)` Reset all bindings on a prepared statement (reset all host parameters to NULL).
`void` `close()` Closes a database connection and finalizes any remaining statements before the closing operation.
`abstract byte[]` `column_blob(long stmt, int col)`
`abstract int` `column_count(long stmt)`
`abstract String` `column_decltype(long stmt, int col)`
`abstract double` `column_double(long stmt, int col)`
`abstract int` `column_int(long stmt, int col)`
`abstract long` `column_long(long stmt, int col)`
`abstract String` `column_name(long stmt, int col)`
`String[]` `column_names(long stmt)` Returns an array of column names in the result set of the SELECT statement.
`abstract String` `column_table_name(long stmt, int col)`
`abstract String` `column_text(long stmt, int col)`
`abstract int` `column_type(long stmt, int col)`
`abstract int` `create_function(String name, Function f)` Create a user defined function with given function name and the function object.
`abstract int` `destroy_function(String name)` De-registers a user defined function
`abstract int` `enable_load_extension(boolean enable)` Enables or disables loading of SQLite extensions.
`void` `exec(String sql)` Executes an SQL statement using the process of compiling, evaluating, and destroying the prepared statement object.
`boolean` `execute(CoreStatement stmt, Object[] vals)`
`int` `executeUpdate(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..
`int` `finalize(CoreStatement stmt)` Destroys a statement.
`protected abstract int` `finalize(long stmt)` Destroys a prepared statement.
`abstract void` `interrupt()` Aborts any pending operation and returns at its earliest opportunity.
`abstract String` `libversion()` Returns the value for SQLITE_VERSION, SQLITE_VERSION_NUMBER, and SQLITE_SOURCE_ID C preprocessor macros that are associated with the library.
`static SQLException` `newSQLException(int errorCode, String errorMessage)` Throws formated SQLException with error code and message.
`void` `open(SQLiteConnection conn, String file, int openFlags)` Creates an SQLite interface to a database for the given connection.
`void` `prepare(CoreStatement stmt)` Complies the an SQL statement.
`protected abstract long` `prepare(String sql)` Complies an SQL statement.
`abstract int` `reset(long stmt)` Sets a prepared statement object back to its initial state, ready to be re-executed.
`abstract int` `restore(String dbName, String sourceFileName, DB.ProgressObserver observer)`
`abstract void` `result_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 void` `result_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 void` `result_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 void` `result_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 void` `result_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 void` `result_null(long context)` Sets the result of an SQL function as NULL with the pointer to the SQLite database context.
`abstract void` `result_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 int` `shared_cache(boolean enable)` Enables or disables the sharing of the database cache and schema data structures between connections to the same database.
`abstract int` `step(long stmt)` Evaluates a statement.
`void` `throwex(int errorCode)` Throws SQLException with error code.
`abstract int` `total_changes()`
`abstract byte[]` `value_blob(Function f, int arg)`
`abstract int` `value_bytes(Function f, int arg)`
`abstract double` `value_double(Function f, int arg)`
`abstract int` `value_int(Function f, int arg)` Accesses the parameter values on the function or aggregate in int data type with the function object and the parameter value.
`abstract long` `value_long(Function f, int arg)`
`abstract String` `value_text(Function f, int arg)`
`abstract int` `value_type(Function f, int arg)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DB

    public DB()

### Method Detail

#### interrupt

    public abstract void interrupt()
                            throws SQLException

Aborts any pending operation and returns at its earliest opportunity.

Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/interrupt.html

#### busy_timeout

    public abstract void busy_timeout(int ms)
                               throws SQLException

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:
  http://www.sqlite.org/c3ref/busy_timeout.html

#### libversion

    public abstract String libversion()
                               throws SQLException

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:
  http://www.sqlite.org/c3ref/libversion.html, http://www.sqlite.org/c3ref/c_source_id.html

#### changes

    public abstract int changes()
                         throws SQLException

Returns:
  Number of rows that were changed, inserted or deleted by the last SQL statement
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/changes.html

#### total_changes

    public abstract int total_changes()
                               throws SQLException

Returns:
  Number of row changes caused by INSERT, UPDATE or DELETE statements since the database connection was opened.
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/total_changes.html

#### shared_cache

    public abstract int shared_cache(boolean enable)
                              throws SQLException

Enables or disables the sharing of the database cache and schema data structures between connections to the same database.

Parameters:
  `enable` - True to enable; false otherwise.
Returns:
  Result Codes
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/enable_shared_cache.html, `SQLiteErrorCode`

#### enable_load_extension

    public abstract int enable_load_extension(boolean enable)
                                       throws SQLException

Enables or disables loading of SQLite extensions.

Parameters:
  `enable` - True to enable; false otherwise.
Returns:
  Result Codes
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/load_extension.html

#### exec

    public final void exec(String sql)
                    throws SQLException

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:
  http://www.sqlite.org/c3ref/exec.html

#### open

    public final void open(SQLiteConnection conn,
            String file,
            int openFlags)
                    throws SQLException

Creates an SQLite interface to a database for the given connection.

Parameters:
  `conn` - The connection.
  `file` - The database.
  `openFlags` - File opening configurations (http://www.sqlite.org/c3ref/c_open_autoproxy.html)
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/open.html

#### close

    public final void close()
                     throws SQLException

Closes a database connection and finalizes any remaining statements before the closing operation.

Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/close.html

#### prepare

    public final void prepare(CoreStatement stmt)
                       throws SQLException

Complies the an SQL statement.

Parameters:
  `stmt` - The SQL statement to compile.
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/prepare.html

#### finalize

    public final int finalize(CoreStatement stmt)
                       throws SQLException

Destroys a statement.

Parameters:
  `stmt` - The statement to destroy.
Returns:
  Result Codes
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/finalize.html

#### _open

    protected abstract void _open(String filename,
             int openFlags)
                           throws SQLException

Creates an SQLite interface to a database with the provided open flags.

Parameters:
  `filename` - The database to open.
  `openFlags` - File opening configurations (http://www.sqlite.org/c3ref/c_open_autoproxy.html)
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/open.html

#### _close

    protected abstract void _close()
                            throws SQLException

Closes the SQLite interface to a database.

Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/close.html

#### _exec

    public abstract int _exec(String sql)
                       throws SQLException

Complies, evaluates, executes and commits an SQL statement.

Parameters:
  `sql` - An SQL statement.
Returns:
  Result Codes
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/exec.html

#### prepare

    protected abstract long prepare(String sql)
                             throws SQLException

Complies an SQL statement.

Parameters:
  `sql` - An SQL statement.
Returns:
  Result Codes
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/prepare.html

#### finalize

    protected abstract int finalize(long stmt)
                             throws SQLException

Destroys a prepared statement.

Parameters:
  `stmt` - Pointer to the statement pointer.
Returns:
  Result Codes
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/finalize.html

#### step

    public abstract int step(long stmt)
                      throws SQLException

Evaluates a statement.

Parameters:
  `stmt` - Pointer to the statement.
Returns:
  Result Codes
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/step.html

#### reset

    public abstract int reset(long stmt)
                       throws SQLException

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:
  http://www.sqlite.org/c3ref/reset.html

#### clear_bindings

    public abstract int clear_bindings(long stmt)
                                throws SQLException

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:
  http://www.sqlite.org/c3ref/clear_bindings.html

#### column_count

    public abstract int column_count(long stmt)
                              throws SQLException

Parameters:
  `stmt` - Pointer to the statement.
Returns:
  Number of columns in the result set returned by the prepared statement.
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/column_count.html

#### column_type

    public abstract int column_type(long stmt,
                  int col)
                             throws SQLException

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:
  http://www.sqlite.org/c3ref/column_blob.html

#### column_decltype

    public abstract String column_decltype(long stmt,
                         int col)
                                    throws SQLException

Parameters:
  `stmt` - Pointer to the statement.
  `col` - Number of column.
Returns:
  Declared type of the table column for prepared statement.
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/column_decltype.html

#### column_table_name

    public abstract String column_table_name(long stmt,
                           int col)
                                      throws SQLException

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:
  http://www.sqlite.org/c3ref/column_database_name.html

#### column_name

    public abstract String column_name(long stmt,
                     int col)
                                throws SQLException

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:
  http://www.sqlite.org/c3ref/column_name.html

#### column_text

    public abstract String column_text(long stmt,
                     int col)
                                throws SQLException

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:
  http://www.sqlite.org/c3ref/column_blob.html

#### column_blob

    public abstract byte[] column_blob(long stmt,
                     int col)
                                throws SQLException

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:
  http://www.sqlite.org/c3ref/column_blob.html

#### column_double

    public abstract double column_double(long stmt,
                       int col)
                                  throws SQLException

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:
  http://www.sqlite.org/c3ref/column_blob.html

#### column_long

    public abstract long column_long(long stmt,
                   int col)
                              throws SQLException

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:
  http://www.sqlite.org/c3ref/column_blob.html

#### column_int

    public abstract int column_int(long stmt,
                 int col)
                            throws SQLException

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:
  http://www.sqlite.org/c3ref/column_blob.html

#### result_null

    public abstract void result_null(long context)
                              throws SQLException

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:
  http://www.sqlite.org/c3ref/result_blob.html

#### result_text

    public abstract void result_text(long context,
                   String val)
                              throws SQLException

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:
  http://www.sqlite.org/c3ref/result_blob.html

#### result_blob

    public abstract void result_blob(long context,
                   byte[] val)
                              throws SQLException

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:
  http://www.sqlite.org/c3ref/result_blob.html

#### result_double

    public abstract void result_double(long context,
                     double val)
                                throws SQLException

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:
  http://www.sqlite.org/c3ref/result_blob.html

#### result_long

    public abstract void result_long(long context,
                   long val)
                              throws SQLException

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:
  http://www.sqlite.org/c3ref/result_blob.html

#### result_int

    public abstract void result_int(long context,
                  int val)
                             throws SQLException

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:
  http://www.sqlite.org/c3ref/result_blob.html

#### result_error

    public abstract void result_error(long context,
                    String err)
                               throws SQLException

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:
  http://www.sqlite.org/c3ref/result_blob.html

#### value_bytes

    public abstract int value_bytes(Function f,
                  int arg)
                             throws SQLException

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 bytes data type.
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/value_blob.html

#### value_text

    public abstract String value_text(Function f,
                    int arg)
                               throws SQLException

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:
  http://www.sqlite.org/c3ref/value_blob.html

#### value_blob

    public abstract byte[] value_blob(Function f,
                    int arg)
                               throws SQLException

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:
  http://www.sqlite.org/c3ref/value_blob.html

#### value_double

    public abstract double value_double(Function f,
                      int arg)
                                 throws SQLException

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:
  http://www.sqlite.org/c3ref/value_blob.html

#### value_long

    public abstract long value_long(Function f,
                  int arg)
                             throws SQLException

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:
  http://www.sqlite.org/c3ref/value_blob.html

#### value_int

    public abstract int value_int(Function f,
                int arg)
                           throws SQLException

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:
  http://www.sqlite.org/c3ref/value_blob.html

#### value_type

    public abstract int value_type(Function f,
                 int arg)
                            throws SQLException

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:
  http://www.sqlite.org/c3ref/value_blob.html

#### create_function

    public abstract int create_function(String name,
                      Function f)
                                 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.
Returns:
  Result Codes
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/create_function.html

#### destroy_function

    public abstract int destroy_function(String name)
                                  throws SQLException

De-registers a user defined function

Parameters:
  `name` - Name of the function to de-registered.
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`

#### 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`

#### column_names

    public final String[] column_names(long stmt)
                                throws SQLException

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

    public final boolean execute(CoreStatement stmt,
                  Object[] vals)
                          throws SQLException

Parameters:
  `stmt` - Stmt object.
  `vals` - Array of parameter values.
Returns:
  True if a row of ResultSet is ready; false otherwise.
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c_interface.html#sqlite_exec

#### executeUpdate

    public final int executeUpdate(CoreStatement stmt,
                    Object[] vals)
                            throws SQLException

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`

#### throwex

    public final void throwex(int errorCode)
                       throws SQLException

Throws SQLException with error code.

Parameters:
  `errorCode` - Error code to be passed.
Throws:
  `SQLException`

#### newSQLException

    public static SQLException newSQLException(int errorCode,
                               String errorMessage)
                                        throws SQLException

Throws formated SQLException with error code and message.

Parameters:
  `errorCode` - Error code to be passed.
  `errorMessage` - Error message to be passed.
Returns:
  Formated SQLException with error code and message.
Throws:
  `SQLException`