Class DB

  • All Implemented Interfaces:
    Codes
    Direct Known Subclasses:
    NativeDB

    public abstract class DB
    extends java.lang.Object
    implements Codes
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  DB.ProgressObserver  
    • Constructor Summary

      Constructors 
      Constructor Description
      DB()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void _close()
      Closes the SQLite interface to a database.
      abstract int _exec​(java.lang.String sql)
      Complies, evaluates, executes and commits an SQL statement.
      protected abstract void _open​(java.lang.String filename, int openFlags)
      Creates an SQLite interface to a database with the provided open flags.
      abstract int backup​(java.lang.String dbName, java.lang.String destFileName, DB.ProgressObserver observer)  
      (package private) abstract int bind_blob​(long stmt, int pos, byte[] v)
      Binds blob value to prepared statements with the pointer to the statement object, the index of the SQL parameter to be set and the value to bind to the parameter.
      (package private) abstract int bind_double​(long stmt, int pos, double v)
      Binds double value to prepared statements with the pointer to the statement object, the index of the SQL parameter to be set and the value to bind to the parameter.
      (package private) abstract int bind_int​(long stmt, int pos, int v)
      Binds int value to prepared statements with the pointer to the statement object, the index of the SQL parameter to be set and the value to bind to the parameter.
      (package private) abstract int bind_long​(long stmt, int pos, long v)
      Binds long value to prepared statements with the pointer to the statement object, the index of the SQL parameter to be set and the value to bind to the parameter.
      (package private) abstract int bind_null​(long stmt, int pos)
      Binds NULL value to prepared statements with the pointer to the statement object and the index of the SQL parameter to be set to NULL.
      (package private) abstract int bind_parameter_count​(long stmt)  
      (package private) abstract int bind_text​(long stmt, int pos, java.lang.String v)
      Binds text value to prepared statements with the pointer to the statement object, the index of the SQL parameter to be set and the value to bind to the parameter.
      abstract void busy_handler​(BusyHandler busyHandler)
      Sets a busy handler that sleeps for a specified amount of time when a table is locked.
      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).
      abstract void clear_progress_handler()  
      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 java.lang.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)  
      (package private) abstract boolean[][] column_metadata​(long stmt)
      Returns an array describing the attributes (not null, primary key and auto increment) of columns.
      abstract java.lang.String column_name​(long stmt, int col)  
      java.lang.String[] column_names​(long stmt)
      Returns an array of column names in the result set of the SELECT statement.
      abstract java.lang.String column_table_name​(long stmt, int col)  
      abstract java.lang.String column_text​(long stmt, int col)  
      abstract int column_type​(long stmt, int col)  
      abstract int create_function​(java.lang.String name, Function f)
      Create a user defined function with given function name and the function object.
      abstract int destroy_function​(java.lang.String name)
      De-registers a user defined function
      abstract int enable_load_extension​(boolean enable)
      Enables or disables loading of SQLite extensions.
      (package private) void ensureAutoCommit()
      SQLite and the JDBC API have very different ideas about the meaning of auto-commit.
      (package private) abstract java.lang.String errmsg()
      Return English-language text that describes the error as either UTF-8 or UTF-16.
      void exec​(java.lang.String sql)
      Executes an SQL statement using the process of compiling, evaluating, and destroying the prepared statement object.
      (package private) boolean execute​(java.lang.String sql)
      Executes the given SQL statement using the one-step query execution interface.
      boolean execute​(CoreStatement stmt, java.lang.Object[] vals)  
      (package private) int[] executeBatch​(long stmt, int count, java.lang.Object[] vals)
      Submits a batch of commands to the database for execution.
      int executeUpdate​(CoreStatement stmt, java.lang.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 int finalize​(long stmt)
      Destroys a prepared statement.
      int finalize​(CoreStatement stmt)
      Destroys a statement.
      (package private) abstract void free_functions()
      Unused as we use the user_data pointer to store a single word.
      abstract void interrupt()
      Aborts any pending operation and returns at its earliest opportunity.
      abstract java.lang.String libversion()
      Returns the value for SQLITE_VERSION, SQLITE_VERSION_NUMBER, and SQLITE_SOURCE_ID C preprocessor macros that are associated with the library.
      private SQLiteException newSQLException​(int errorCode)
      Throws SQL Exception with error code.
      static SQLiteException newSQLException​(int errorCode, java.lang.String errorMessage)
      Throws formated SQLException with error code and message.
      void open​(SQLiteConnection conn, java.lang.String file, int openFlags)
      Creates an SQLite interface to a database for the given connection.
      protected abstract long prepare​(java.lang.String sql)
      Complies an SQL statement.
      void prepare​(CoreStatement stmt)
      Complies the an SQL statement.
      abstract void register_progress_handler​(int vmCalls, ProgressHandler progressHandler)
      Progress handler
      abstract int reset​(long stmt)
      Sets a prepared statement object back to its initial state, ready to be re-executed.
      abstract int restore​(java.lang.String dbName, java.lang.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, java.lang.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, java.lang.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.
      (package private) int sqlbind​(long stmt, int pos, java.lang.Object v)
      Bind values to prepared statements
      abstract int step​(long stmt)
      Evaluates a statement.
      (package private) void throwex()
      Throws SQLException with error message.
      void throwex​(int errorCode)
      Throws SQLException with error code.
      (package private) static void throwex​(int errorCode, java.lang.String errorMessage)
      Throws SQL Exception with error code and message.
      abstract int total_changes()  
      abstract byte[] value_blob​(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 java.lang.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
    • Field Detail

      • conn

        SQLiteConnection conn
        The JDBC Connection that 'owns' this database instance.
      • begin

        long begin
        The "begin;"and "commit;" statement handles.
      • commit

        long commit
      • stmts

        private final java.util.Map<java.lang.Long,​CoreStatement> stmts
        Tracer for statements to avoid unfinalized statements on db close.
    • Constructor Detail

      • DB

        public DB()
    • Method Detail

      • interrupt

        public abstract void interrupt()
                                throws java.sql.SQLException
        Aborts any pending operation and returns at its earliest opportunity.
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/interrupt.html
      • busy_timeout

        public abstract void busy_timeout​(int ms)
                                   throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/busy_timeout.html
      • errmsg

        abstract java.lang.String errmsg()
                                  throws java.sql.SQLException
        Return English-language text that describes the error as either UTF-8 or UTF-16.
        Returns:
        Error description in English.
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/errcode.html
      • changes

        public abstract int changes()
                             throws java.sql.SQLException
        Returns:
        Number of rows that were changed, inserted or deleted by the last SQL statement
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/changes.html
      • total_changes

        public abstract int total_changes()
                                   throws java.sql.SQLException
        Returns:
        Number of row changes caused by INSERT, UPDATE or DELETE statements since the database connection was opened.
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/total_changes.html
      • shared_cache

        public abstract int shared_cache​(boolean enable)
                                  throws java.sql.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:
        java.sql.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 java.sql.SQLException
        Enables or disables loading of SQLite extensions.
        Parameters:
        enable - True to enable; false otherwise.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/load_extension.html
      • exec

        public final void exec​(java.lang.String sql)
                        throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/exec.html
      • close

        public final void close()
                         throws java.sql.SQLException
        Closes a database connection and finalizes any remaining statements before the closing operation.
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/close.html
      • _close

        protected abstract void _close()
                                throws java.sql.SQLException
        Closes the SQLite interface to a database.
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/close.html
      • _exec

        public abstract int _exec​(java.lang.String sql)
                           throws java.sql.SQLException
        Complies, evaluates, executes and commits an SQL statement.
        Parameters:
        sql - An SQL statement.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/exec.html
      • prepare

        protected abstract long prepare​(java.lang.String sql)
                                 throws java.sql.SQLException
        Complies an SQL statement.
        Parameters:
        sql - An SQL statement.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/prepare.html
      • finalize

        protected abstract int finalize​(long stmt)
                                 throws java.sql.SQLException
        Destroys a prepared statement.
        Parameters:
        stmt - Pointer to the statement pointer.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/finalize.html
      • step

        public abstract int step​(long stmt)
                          throws java.sql.SQLException
        Evaluates a statement.
        Parameters:
        stmt - Pointer to the statement.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/step.html
      • reset

        public abstract int reset​(long stmt)
                           throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/reset.html
      • clear_bindings

        public abstract int clear_bindings​(long stmt)
                                    throws java.sql.SQLException
        Reset all bindings on a prepared statement (reset all host parameters to NULL).
        Parameters:
        stmt - Pointer to the statement.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/clear_bindings.html
      • bind_parameter_count

        abstract int bind_parameter_count​(long stmt)
                                   throws java.sql.SQLException
        Parameters:
        stmt - Pointer to the statement.
        Returns:
        Number of parameters in a prepared SQL.
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/bind_parameter_count.html
      • column_count

        public abstract int column_count​(long stmt)
                                  throws java.sql.SQLException
        Parameters:
        stmt - Pointer to the statement.
        Returns:
        Number of columns in the result set returned by the prepared statement.
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/column_count.html
      • column_type

        public abstract int column_type​(long stmt,
                                        int col)
                                 throws java.sql.SQLException
        Parameters:
        stmt - Pointer to the statement.
        col - Number of column.
        Returns:
        Datatype code for the initial data type of the result column.
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/column_blob.html
      • column_decltype

        public abstract java.lang.String column_decltype​(long stmt,
                                                         int col)
                                                  throws java.sql.SQLException
        Parameters:
        stmt - Pointer to the statement.
        col - Number of column.
        Returns:
        Declared type of the table column for prepared statement.
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/column_decltype.html
      • column_table_name

        public abstract java.lang.String column_table_name​(long stmt,
                                                           int col)
                                                    throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/column_database_name.html
      • column_name

        public abstract java.lang.String column_name​(long stmt,
                                                     int col)
                                              throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/column_name.html
      • column_text

        public abstract java.lang.String column_text​(long stmt,
                                                     int col)
                                              throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/column_blob.html
      • column_blob

        public abstract byte[] column_blob​(long stmt,
                                           int col)
                                    throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/column_blob.html
      • column_double

        public abstract double column_double​(long stmt,
                                             int col)
                                      throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/column_blob.html
      • column_long

        public abstract long column_long​(long stmt,
                                         int col)
                                  throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/column_blob.html
      • column_int

        public abstract int column_int​(long stmt,
                                       int col)
                                throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/column_blob.html
      • bind_null

        abstract int bind_null​(long stmt,
                               int pos)
                        throws java.sql.SQLException
        Binds NULL value to prepared statements with the pointer to the statement object and the index of the SQL parameter to be set to NULL.
        Parameters:
        stmt - Pointer to the statement.
        pos - The index of the SQL parameter to be set to NULL.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
      • bind_int

        abstract int bind_int​(long stmt,
                              int pos,
                              int v)
                       throws java.sql.SQLException
        Binds int value to prepared statements with the pointer to the statement object, the index of the SQL parameter to be set and the value to bind to the parameter.
        Parameters:
        stmt - Pointer to the statement.
        pos - The index of the SQL parameter to be set.
        v - Value to bind to the parameter.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/bind_blob.html
      • bind_long

        abstract int bind_long​(long stmt,
                               int pos,
                               long v)
                        throws java.sql.SQLException
        Binds long value to prepared statements with the pointer to the statement object, the index of the SQL parameter to be set and the value to bind to the parameter.
        Parameters:
        stmt - Pointer to the statement.
        pos - The index of the SQL parameter to be set.
        v - Value to bind to the parameter.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/bind_blob.html
      • bind_double

        abstract int bind_double​(long stmt,
                                 int pos,
                                 double v)
                          throws java.sql.SQLException
        Binds double value to prepared statements with the pointer to the statement object, the index of the SQL parameter to be set and the value to bind to the parameter.
        Parameters:
        stmt - Pointer to the statement.
        pos - Index of the SQL parameter to be set.
        v - Value to bind to the parameter.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/bind_blob.html
      • bind_text

        abstract int bind_text​(long stmt,
                               int pos,
                               java.lang.String v)
                        throws java.sql.SQLException
        Binds text value to prepared statements with the pointer to the statement object, the index of the SQL parameter to be set and the value to bind to the parameter.
        Parameters:
        stmt - Pointer to the statement.
        pos - Index of the SQL parameter to be set.
        v - value to bind to the parameter.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/bind_blob.html
      • bind_blob

        abstract int bind_blob​(long stmt,
                               int pos,
                               byte[] v)
                        throws java.sql.SQLException
        Binds blob value to prepared statements with the pointer to the statement object, the index of the SQL parameter to be set and the value to bind to the parameter.
        Parameters:
        stmt - Pointer to the statement.
        pos - Index of the SQL parameter to be set.
        v - Value to bind to the parameter.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/bind_blob.html
      • result_null

        public abstract void result_null​(long context)
                                  throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/result_blob.html
      • result_text

        public abstract void result_text​(long context,
                                         java.lang.String val)
                                  throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/result_blob.html
      • result_blob

        public abstract void result_blob​(long context,
                                         byte[] val)
                                  throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/result_blob.html
      • result_double

        public abstract void result_double​(long context,
                                           double val)
                                    throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/result_blob.html
      • result_long

        public abstract void result_long​(long context,
                                         long val)
                                  throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/result_blob.html
      • result_int

        public abstract void result_int​(long context,
                                        int val)
                                 throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/result_blob.html
      • result_error

        public abstract void result_error​(long context,
                                          java.lang.String err)
                                   throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/result_blob.html
      • value_text

        public abstract java.lang.String value_text​(Function f,
                                                    int arg)
                                             throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/value_blob.html
      • value_blob

        public abstract byte[] value_blob​(Function f,
                                          int arg)
                                   throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/value_blob.html
      • value_double

        public abstract double value_double​(Function f,
                                            int arg)
                                     throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/value_blob.html
      • value_long

        public abstract long value_long​(Function f,
                                        int arg)
                                 throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/value_blob.html
      • value_int

        public abstract int value_int​(Function f,
                                      int arg)
                               throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/value_blob.html
      • value_type

        public abstract int value_type​(Function f,
                                       int arg)
                                throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/value_blob.html
      • create_function

        public abstract int create_function​(java.lang.String name,
                                            Function f)
                                     throws java.sql.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:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/create_function.html
      • destroy_function

        public abstract int destroy_function​(java.lang.String name)
                                      throws java.sql.SQLException
        De-registers a user defined function
        Parameters:
        name - Name of the function to de-registered.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
      • free_functions

        abstract void free_functions()
                              throws java.sql.SQLException
        Unused as we use the user_data pointer to store a single word.
        Throws:
        java.sql.SQLException
      • backup

        public abstract int backup​(java.lang.String dbName,
                                   java.lang.String destFileName,
                                   DB.ProgressObserver observer)
                            throws java.sql.SQLException
        Parameters:
        dbName - Database name to be backed up.
        destFileName - Target backup file name.
        observer - ProgressObserver object.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
      • restore

        public abstract int restore​(java.lang.String dbName,
                                    java.lang.String sourceFileName,
                                    DB.ProgressObserver observer)
                             throws java.sql.SQLException
        Parameters:
        dbName - Database name for restoring data.
        sourceFileName - Source file name.
        observer - ProgressObserver object.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
      • register_progress_handler

        public abstract void register_progress_handler​(int vmCalls,
                                                       ProgressHandler progressHandler)
                                                throws java.sql.SQLException
        Progress handler
        Throws:
        java.sql.SQLException
      • clear_progress_handler

        public abstract void clear_progress_handler()
                                             throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • column_metadata

        abstract boolean[][] column_metadata​(long stmt)
                                      throws java.sql.SQLException
        Returns an array describing the attributes (not null, primary key and auto increment) of columns.
        Parameters:
        stmt - Pointer to the statement.
        Returns:
        Column attribute array.
        index[col][0] = true if column constrained NOT NULL;
        index[col][1] = true if column is part of the primary key;
        index[col][2] = true if column is auto-increment.
        Throws:
        java.sql.SQLException
      • column_names

        public final java.lang.String[] column_names​(long stmt)
                                              throws java.sql.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:
        java.sql.SQLException
      • sqlbind

        final int sqlbind​(long stmt,
                          int pos,
                          java.lang.Object v)
                   throws java.sql.SQLException
        Bind values to prepared statements
        Parameters:
        stmt - Pointer to the statement.
        pos - Index of the SQL parameter to be set to NULL.
        v - Value to bind to the parameter.
        Returns:
        Result Codes
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/bind_blob.html
      • executeBatch

        final int[] executeBatch​(long stmt,
                                 int count,
                                 java.lang.Object[] vals)
                          throws java.sql.SQLException
        Submits a batch of commands to the database for execution.
        Parameters:
        stmt - Pointer of Stmt object.
        count - Number of SQL statements.
        vals - Array of parameter values.
        Returns:
        Array of the number of rows changed or inserted or deleted for each command if all commands execute successfully;
        Throws:
        java.sql.SQLException
        See Also:
        Statement.executeBatch()
      • execute

        public final boolean execute​(CoreStatement stmt,
                                     java.lang.Object[] vals)
                              throws java.sql.SQLException
        Parameters:
        stmt - Stmt object.
        vals - Array of parameter values.
        Returns:
        True if a row of ResultSet is ready; false otherwise.
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c_interface.html#sqlite_exec
      • execute

        final boolean execute​(java.lang.String sql)
                       throws java.sql.SQLException
        Executes the given SQL statement using the one-step query execution interface.
        Parameters:
        sql - SQL statement to be executed.
        Returns:
        True if a row of ResultSet is ready; false otherwise.
        Throws:
        java.sql.SQLException
        See Also:
        http://www.sqlite.org/c3ref/exec.html
      • executeUpdate

        public final int executeUpdate​(CoreStatement stmt,
                                       java.lang.Object[] vals)
                                throws java.sql.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:
        java.sql.SQLException
      • throwex

        final void throwex()
                    throws java.sql.SQLException
        Throws SQLException with error message.
        Throws:
        java.sql.SQLException
      • throwex

        public final void throwex​(int errorCode)
                           throws java.sql.SQLException
        Throws SQLException with error code.
        Parameters:
        errorCode - Error code to be passed.
        Throws:
        java.sql.SQLException
      • throwex

        static final void throwex​(int errorCode,
                                  java.lang.String errorMessage)
                           throws SQLiteException
        Throws SQL Exception with error code and message.
        Parameters:
        errorCode - Error code to be passed.
        errorMessage - Error message to be passed.
        Throws:
        java.sql.SQLException
        SQLiteException
      • newSQLException

        public static SQLiteException newSQLException​(int errorCode,
                                                      java.lang.String errorMessage)
        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:
        java.sql.SQLException
      • newSQLException

        private SQLiteException newSQLException​(int errorCode)
                                         throws java.sql.SQLException
        Throws SQL Exception with error code.
        Parameters:
        errorCode - Error code to be passed.
        Returns:
        SQLException with error code and message.
        Throws:
        java.sql.SQLException
      • ensureAutoCommit

        final void ensureAutoCommit()
                             throws java.sql.SQLException
        SQLite and the JDBC API have very different ideas about the meaning of auto-commit. Under JDBC, when executeUpdate() returns in auto-commit mode (the default), the programmer assumes the data has been written to disk. In SQLite however, a call to sqlite3_step() with an INSERT statement can return SQLITE_OK, and yet the data is still in limbo. This limbo appears when another statement on the database is active, e.g. a SELECT. SQLite auto-commit waits until the final read statement finishes, and then writes whatever updates have already been OKed. So if a program crashes before the reads are complete, data is lost. E.g: select begins insert select continues select finishes Works as expected, however select beings insert select continues crash Results in the data never being written to disk. As a solution, we call "commit" after every statement in auto-commit mode.
        Throws:
        java.sql.SQLException