Package org.sqlite.core
Class NativeDB
- java.lang.Object
-
- org.sqlite.core.DB
-
- org.sqlite.core.NativeDB
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.sqlite.core.DB
DB.ProgressObserver
-
-
Field Summary
Fields Modifier and Type Field Description private longbusyHandlerbusy handler pointer to JNI global busyhandler reference.private longcommitListenerprivate static intDEFAULT_BACKUP_BUSY_SLEEP_TIME_MILLISprivate static intDEFAULT_BACKUP_NUM_BUSY_BEFORE_FAILprivate static intDEFAULT_PAGES_PER_BACKUP_STEPprivate static booleanisLoadedprivate static booleanloadSucceededprivate static Loggerloggerprivate longpointerSQLite connection handle.private longprogressHandlerhandler pointer to JNI global progressHandler reference.private longupdateListener-
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 Description NativeDB(java.lang.String url, java.lang.String fileName, SQLiteConfig config)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_close()Closes the SQLite interface to a database.int_exec(java.lang.String sql)Complies, evaluates, executes and commits an SQL statement.(package private) int_exec_utf8(byte[] sqlUtf8)protected void_open(java.lang.String file, int openFlags)Creates an SQLite interface to a database with the provided open flags.(package private) void_open_utf8(byte[] fileUtf8, int openFlags)(package private) intbackup(byte[] dbNameUtf8, byte[] destFileNameUtf8, DB.ProgressObserver observer, int sleepTimeMillis, int nTimeouts, int pagesPerStep)intbackup(java.lang.String dbName, java.lang.String destFileName, DB.ProgressObserver observer)intbackup(java.lang.String dbName, java.lang.String destFileName, DB.ProgressObserver observer, int sleepTimeMillis, int nTimeouts, int pagesPerStep)(package private) intbind_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) intbind_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) intbind_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) intbind_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) intbind_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) intbind_parameter_count(long stmt)(package private) intbind_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.(package private) intbind_text_utf8(long stmt, int pos, byte[] vUtf8)voidbusy_handler(BusyHandler busyHandler)Sets a busy handler that sleeps for a specified amount of time when a table is locked.voidbusy_timeout(int ms)Sets a busy handler that sleeps for a specified amount of time when a table is locked.longchanges()intclear_bindings(long stmt)Reset all bindings on a prepared statement (reset all host parameters to NULL).voidclear_progress_handler()byte[]column_blob(long stmt, int col)intcolumn_count(long stmt)java.lang.Stringcolumn_decltype(long stmt, int col)(package private) java.nio.ByteBuffercolumn_decltype_utf8(long stmt, int col)doublecolumn_double(long stmt, int col)intcolumn_int(long stmt, int col)longcolumn_long(long stmt, int col)(package private) boolean[][]column_metadata(long stmt)Provides metadata for table columns.java.lang.Stringcolumn_name(long stmt, int col)(package private) java.nio.ByteBuffercolumn_name_utf8(long stmt, int col)java.lang.Stringcolumn_table_name(long stmt, int col)(package private) java.nio.ByteBuffercolumn_table_name_utf8(long stmt, int col)java.lang.Stringcolumn_text(long stmt, int col)(package private) java.nio.ByteBuffercolumn_text_utf8(long stmt, int col)intcolumn_type(long stmt, int col)intcreate_collation(java.lang.String name, Collation coll)Create a user defined collation with given collation name and the collation object.(package private) intcreate_collation_utf8(byte[] nameUtf8, Collation coll)intcreate_function(java.lang.String name, Function func, int nArgs, int flags)Create a user defined function with given function name and the function object.(package private) intcreate_function_utf8(byte[] nameUtf8, Function func, int nArgs, int flags)voiddeserialize(java.lang.String schema, byte[] buff)intdestroy_collation(java.lang.String name)Create a user defined collation with given collation name and the collation object.(package private) intdestroy_collation_utf8(byte[] nameUtf8)intdestroy_function(java.lang.String name)De-registers a user defined function(package private) intdestroy_function_utf8(byte[] nameUtf8)intenable_load_extension(boolean enable)Enables or disables loading of SQLite extensions.(package private) java.lang.Stringerrmsg()Return English-language text that describes the error as either UTF-8 or UTF-16.(package private) java.nio.ByteBuffererrmsg_utf8()protected intfinalize(long stmt)Destroys a prepared statement.(package private) longgetBusyHandler()Getter for native pointer to validate memory is properly cleaned up in unit tests(package private) longgetCommitListener()Getter for native pointer to validate memory is properly cleaned up in unit tests(package private) longgetProgressHandler()Getter for native pointer to validate memory is properly cleaned up in unit tests(package private) longgetUpdateListener()Getter for native pointer to validate memory is properly cleaned up in unit testsvoidinterrupt()Aborts any pending operation and returns at its earliest opportunity.java.lang.Stringlibversion()Returns the value for SQLITE_VERSION, SQLITE_VERSION_NUMBER, and SQLITE_SOURCE_ID C preprocessor macros that are associated with the library.(package private) java.nio.ByteBufferlibversion_utf8()intlimit(int id, int value)static booleanload()Loads the SQLite interface backend.private byte[]nameToUtf8ByteArray(java.lang.String nameType, java.lang.String name)protected SafeStmtPtrprepare(java.lang.String sql)Complies an SQL statement.(package private) longprepare_utf8(byte[] sqlUtf8)voidregister_progress_handler(int vmCalls, ProgressHandler progressHandler)Progress handlerintreset(long stmt)Sets a prepared statement object back to its initial state, ready to be re-executed.(package private) intrestore(byte[] dbNameUtf8, byte[] sourceFileName, DB.ProgressObserver observer, int sleepTimeMillis, int nTimeouts, int pagesPerStep)intrestore(java.lang.String dbName, java.lang.String sourceFileName, DB.ProgressObserver observer)intrestore(java.lang.String dbName, java.lang.String sourceFileName, DB.ProgressObserver observer, int sleepTimeMillis, int nTimeouts, int pagesPerStep)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.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.voidresult_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.(package private) voidresult_error_utf8(long context, byte[] errUtf8)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.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.voidresult_null(long context)Sets the result of an SQL function as NULL with the pointer to the SQLite database context.voidresult_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.(package private) voidresult_text_utf8(long context, byte[] valUtf8)byte[]serialize(java.lang.String schema)(package private) voidset_commit_listener(boolean enabled)(package private) voidset_update_listener(boolean enabled)intshared_cache(boolean enable)Enables or disables the sharing of the database cache and schema data structures between connections to the same database.intstep(long stmt)Evaluates a statement.(package private) static byte[]stringToUtf8ByteArray(java.lang.String str)(package private) static voidthrowex(java.lang.String msg)Throws an SQLException.longtotal_changes()(package private) static java.lang.Stringutf8ByteBufferToString(java.nio.ByteBuffer buffer)byte[]value_blob(Function f, int arg)doublevalue_double(Function f, int arg)intvalue_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.longvalue_long(Function f, int arg)java.lang.Stringvalue_text(Function f, int arg)(package private) java.nio.ByteBuffervalue_text_utf8(Function f, int argUtf8)intvalue_type(Function f, int arg)-
Methods inherited from class org.sqlite.core.DB
addCommitListener, addUpdateListener, close, column_names, ensureAutoCommit, exec, execute, execute, executeBatch, executeUpdate, finalize, getConfig, getUrl, isClosed, newSQLException, onCommit, onUpdate, open, prepare, removeCommitListener, removeUpdateListener, sqlbind, throwex, throwex, throwex
-
-
-
-
Field Detail
-
logger
private static final Logger logger
-
DEFAULT_BACKUP_BUSY_SLEEP_TIME_MILLIS
private static final int DEFAULT_BACKUP_BUSY_SLEEP_TIME_MILLIS
- See Also:
- Constant Field Values
-
DEFAULT_BACKUP_NUM_BUSY_BEFORE_FAIL
private static final int DEFAULT_BACKUP_NUM_BUSY_BEFORE_FAIL
- See Also:
- Constant Field Values
-
DEFAULT_PAGES_PER_BACKUP_STEP
private static final int DEFAULT_PAGES_PER_BACKUP_STEP
- See Also:
- Constant Field Values
-
pointer
private long pointer
SQLite connection handle.
-
isLoaded
private static boolean isLoaded
-
loadSucceeded
private static boolean loadSucceeded
-
busyHandler
private long busyHandler
busy handler pointer to JNI global busyhandler reference.
-
commitListener
private long commitListener
-
updateListener
private long updateListener
-
progressHandler
private long progressHandler
handler pointer to JNI global progressHandler reference.
-
-
Constructor Detail
-
NativeDB
public NativeDB(java.lang.String url, java.lang.String fileName, SQLiteConfig config) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
-
Method Detail
-
load
public static boolean load() throws java.lang.ExceptionLoads the SQLite interface backend.- Returns:
- True if the SQLite JDBC driver is successfully loaded; false otherwise.
- Throws:
java.lang.Exception
-
_open
protected void _open(java.lang.String file, int openFlags) throws java.sql.SQLExceptionDescription copied from class:DBCreates an SQLite interface to a database with the provided open flags.- Specified by:
_openin classDB- Parameters:
file- The database to open.openFlags- File opening configurations (https://www.sqlite.org/c3ref/c_open_autoproxy.html)- Throws:
java.sql.SQLException- See Also:
DB._open(java.lang.String, int)
-
_open_utf8
void _open_utf8(byte[] fileUtf8, int openFlags) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
_close
protected void _close() throws java.sql.SQLExceptionDescription copied from class:DBCloses the SQLite interface to a database.- Specified by:
_closein classDB- Throws:
java.sql.SQLException- See Also:
DB._close()
-
_exec
public int _exec(java.lang.String sql) throws java.sql.SQLExceptionDescription copied from class:DBComplies, evaluates, executes and commits an SQL statement.- Specified by:
_execin classDB- Parameters:
sql- An SQL statement.- Returns:
- Result Codes
- Throws:
java.sql.SQLException- See Also:
DB._exec(java.lang.String)
-
_exec_utf8
int _exec_utf8(byte[] sqlUtf8) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
shared_cache
public int shared_cache(boolean enable)
Description copied from class:DBEnables or disables the sharing of the database cache and schema data structures between connections to the same database.- Specified by:
shared_cachein classDB- Parameters:
enable- True to enable; false otherwise.- Returns:
- Result Codes
- See Also:
DB.shared_cache(boolean)
-
enable_load_extension
public int enable_load_extension(boolean enable)
Description copied from class:DBEnables or disables loading of SQLite extensions.- Specified by:
enable_load_extensionin classDB- Parameters:
enable- True to enable; false otherwise.- Returns:
- Result Codes
- See Also:
DB.enable_load_extension(boolean)
-
interrupt
public void interrupt()
Description copied from class:DBAborts any pending operation and returns at its earliest opportunity.- Specified by:
interruptin classDB- See Also:
DB.interrupt()
-
busy_timeout
public void busy_timeout(int ms)
Description copied from class:DBSets a busy handler that sleeps for a specified amount of time when a table is locked.- Specified by:
busy_timeoutin classDB- Parameters:
ms- Time to sleep in milliseconds.- See Also:
DB.busy_timeout(int)
-
busy_handler
public void busy_handler(BusyHandler busyHandler)
Description copied from class:DBSets a busy handler that sleeps for a specified amount of time when a table is locked.- Specified by:
busy_handlerin classDB- See Also:
DB.busy_handler(BusyHandler)
-
prepare
protected SafeStmtPtr prepare(java.lang.String sql) throws java.sql.SQLException
Description copied from class:DBComplies an SQL statement.- Specified by:
preparein classDB- Parameters:
sql- An SQL statement.- Returns:
- Result Codes
- Throws:
java.sql.SQLException- See Also:
DB.prepare(java.lang.String)
-
prepare_utf8
long prepare_utf8(byte[] sqlUtf8) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
errmsg
java.lang.String errmsg()
Description copied from class:DBReturn English-language text that describes the error as either UTF-8 or UTF-16.- Specified by:
errmsgin classDB- Returns:
- Error description in English.
- See Also:
DB.errmsg()
-
errmsg_utf8
java.nio.ByteBuffer errmsg_utf8()
-
libversion
public java.lang.String libversion()
Description copied from class:DBReturns the value for SQLITE_VERSION, SQLITE_VERSION_NUMBER, and SQLITE_SOURCE_ID C preprocessor macros that are associated with the library.- Specified by:
libversionin classDB- Returns:
- Compile-time SQLite version information.
- See Also:
DB.libversion()
-
libversion_utf8
java.nio.ByteBuffer libversion_utf8()
-
changes
public long changes()
- Specified by:
changesin classDB- Returns:
- Number of rows that were changed, inserted or deleted by the last SQL statement
- See Also:
DB.changes()
-
total_changes
public long total_changes()
- Specified by:
total_changesin classDB- Returns:
- Number of row changes caused by INSERT, UPDATE or DELETE statements since the database connection was opened.
- See Also:
DB.total_changes()
-
finalize
protected int finalize(long stmt)
Description copied from class:DBDestroys a prepared statement.- Specified by:
finalizein classDB- Parameters:
stmt- Pointer to the statement pointer.- Returns:
- Result Codes
- See Also:
DB.finalize(long)
-
step
public int step(long stmt)
Description copied from class:DBEvaluates a statement.- Specified by:
stepin classDB- Parameters:
stmt- Pointer to the statement.- Returns:
- Result Codes
- See Also:
DB.step(long)
-
reset
public int reset(long stmt)
Description copied from class:DBSets a prepared statement object back to its initial state, ready to be re-executed.- Specified by:
resetin classDB- Parameters:
stmt- Pointer to the statement.- Returns:
- Result Codes
- See Also:
DB.reset(long)
-
clear_bindings
public int clear_bindings(long stmt)
Description copied from class:DBReset all bindings on a prepared statement (reset all host parameters to NULL).- Specified by:
clear_bindingsin classDB- Parameters:
stmt- Pointer to the statement.- Returns:
- Result Codes
- See Also:
DB.clear_bindings(long)
-
bind_parameter_count
int bind_parameter_count(long stmt)
- Specified by:
bind_parameter_countin classDB- Parameters:
stmt- Pointer to the statement.- Returns:
- Number of parameters in a prepared SQL.
- See Also:
DB.bind_parameter_count(long)
-
column_count
public int column_count(long stmt)
- Specified by:
column_countin classDB- Parameters:
stmt- Pointer to the statement.- Returns:
- Number of columns in the result set returned by the prepared statement.
- See Also:
DB.column_count(long)
-
column_type
public int column_type(long stmt, int col)- Specified by:
column_typein classDB- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- Datatype code for the initial data type of the result column.
- See Also:
DB.column_type(long, int)
-
column_decltype
public java.lang.String column_decltype(long stmt, int col)- Specified by:
column_decltypein classDB- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- Declared type of the table column for prepared statement.
- See Also:
DB.column_decltype(long, int)
-
column_decltype_utf8
java.nio.ByteBuffer column_decltype_utf8(long stmt, int col)
-
column_table_name
public java.lang.String column_table_name(long stmt, int col)- Specified by:
column_table_namein classDB- 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.
- See Also:
DB.column_table_name(long, int)
-
column_table_name_utf8
java.nio.ByteBuffer column_table_name_utf8(long stmt, int col)
-
column_name
public java.lang.String column_name(long stmt, int col)- Specified by:
column_namein classDB- 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.
- See Also:
DB.column_name(long, int)
-
column_name_utf8
java.nio.ByteBuffer column_name_utf8(long stmt, int col)
-
column_text
public java.lang.String column_text(long stmt, int col)- Specified by:
column_textin classDB- 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.
- See Also:
DB.column_text(long, int)
-
column_text_utf8
java.nio.ByteBuffer column_text_utf8(long stmt, int col)
-
column_blob
public byte[] column_blob(long stmt, int col)- Specified by:
column_blobin classDB- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- BLOB value of the column in the result set of a SELECT statement
- See Also:
DB.column_blob(long, int)
-
column_double
public double column_double(long stmt, int col)- Specified by:
column_doublein classDB- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- DOUBLE value of the column in the result set of a SELECT statement
- See Also:
DB.column_double(long, int)
-
column_long
public long column_long(long stmt, int col)- Specified by:
column_longin classDB- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- LONG value of the column in the result set of a SELECT statement.
- See Also:
DB.column_long(long, int)
-
column_int
public int column_int(long stmt, int col)- Specified by:
column_intin classDB- Parameters:
stmt- Pointer to the statement.col- Number of column.- Returns:
- INT value of column in the result set of a SELECT statement.
- See Also:
DB.column_int(long, int)
-
bind_null
int bind_null(long stmt, int pos)Description copied from class:DBBinds NULL value to prepared statements with the pointer to the statement object and the index of the SQL parameter to be set to NULL.- Specified by:
bind_nullin classDB- Parameters:
stmt- Pointer to the statement.pos- The index of the SQL parameter to be set to NULL.- Returns:
- Result Codes
- See Also:
DB.bind_null(long, int)
-
bind_int
int bind_int(long stmt, int pos, int v)Description copied from class:DBBinds 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.- Specified by:
bind_intin classDB- 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
- See Also:
DB.bind_int(long, int, int)
-
bind_long
int bind_long(long stmt, int pos, long v)Description copied from class:DBBinds 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.- Specified by:
bind_longin classDB- 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
- See Also:
DB.bind_long(long, int, long)
-
bind_double
int bind_double(long stmt, int pos, double v)Description copied from class:DBBinds 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.- Specified by:
bind_doublein classDB- 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
- See Also:
DB.bind_double(long, int, double)
-
bind_text
int bind_text(long stmt, int pos, java.lang.String v)Description copied from class:DBBinds 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.- Specified by:
bind_textin classDB- 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
- See Also:
DB.bind_text(long, int, java.lang.String)
-
bind_text_utf8
int bind_text_utf8(long stmt, int pos, byte[] vUtf8)
-
bind_blob
int bind_blob(long stmt, int pos, byte[] v)Description copied from class:DBBinds 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.- Specified by:
bind_blobin classDB- 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
- See Also:
DB.bind_blob(long, int, byte[])
-
result_null
public void result_null(long context)
Description copied from class:DBSets the result of an SQL function as NULL with the pointer to the SQLite database context.- Specified by:
result_nullin classDB- Parameters:
context- Pointer to the SQLite database context.- See Also:
DB.result_null(long)
-
result_text
public void result_text(long context, java.lang.String val)Description copied from class:DBSets 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.- Specified by:
result_textin classDB- Parameters:
context- Pointer to the SQLite database context.val- Result value of an SQL function.- See Also:
DB.result_text(long, java.lang.String)
-
result_text_utf8
void result_text_utf8(long context, byte[] valUtf8)
-
result_blob
public void result_blob(long context, byte[] val)Description copied from class:DBSets 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.- Specified by:
result_blobin classDB- Parameters:
context- Pointer to the SQLite database context.val- Result value of an SQL function.- See Also:
DB.result_blob(long, byte[])
-
result_double
public void result_double(long context, double val)Description copied from class:DBSets 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.- Specified by:
result_doublein classDB- Parameters:
context- Pointer to the SQLite database context.val- Result value of an SQL function.- See Also:
DB.result_double(long, double)
-
result_long
public void result_long(long context, long val)Description copied from class:DBSets 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.- Specified by:
result_longin classDB- Parameters:
context- Pointer to the SQLite database context.val- Result value of an SQL function.- See Also:
DB.result_long(long, long)
-
result_int
public void result_int(long context, int val)Description copied from class:DBSets 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.- Specified by:
result_intin classDB- Parameters:
context- Pointer to the SQLite database context.val- Result value of an SQL function.- See Also:
DB.result_int(long, int)
-
result_error
public void result_error(long context, java.lang.String err)Description copied from class:DBSets the result of an SQL function as an error with the pointer to the SQLite database context and the the error of String.- Specified by:
result_errorin classDB- Parameters:
context- Pointer to the SQLite database context.err- Error result of an SQL function.- See Also:
DB.result_error(long, java.lang.String)
-
result_error_utf8
void result_error_utf8(long context, byte[] errUtf8)
-
value_text
public java.lang.String value_text(Function f, int arg)
- Specified by:
value_textin classDB- 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.
- See Also:
DB.value_text(org.sqlite.Function, int)
-
value_text_utf8
java.nio.ByteBuffer value_text_utf8(Function f, int argUtf8)
-
value_blob
public byte[] value_blob(Function f, int arg)
- Specified by:
value_blobin classDB- 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.
- See Also:
DB.value_blob(org.sqlite.Function, int)
-
value_double
public double value_double(Function f, int arg)
- Specified by:
value_doublein classDB- 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
- See Also:
DB.value_double(org.sqlite.Function, int)
-
value_long
public long value_long(Function f, int arg)
- Specified by:
value_longin classDB- 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.
- See Also:
DB.value_long(org.sqlite.Function, int)
-
value_int
public int value_int(Function f, int arg)
Description copied from class:DBAccesses the parameter values on the function or aggregate in int data type with the function object and the parameter value.- Specified by:
value_intin classDB- 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.
- See Also:
DB.value_int(org.sqlite.Function, int)
-
value_type
public int value_type(Function f, int arg)
- Specified by:
value_typein classDB- 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.
- See Also:
DB.value_type(org.sqlite.Function, int)
-
create_function
public int create_function(java.lang.String name, Function func, int nArgs, int flags) throws java.sql.SQLExceptionDescription copied from class:DBCreate a user defined function with given function name and the function object.- Specified by:
create_functionin classDB- Parameters:
name- The function name to be created.func- SQLite function object.flags- Extra flags to use when creating the function, such asFunction.FLAG_DETERMINISTIC- Returns:
- Result Codes
- Throws:
java.sql.SQLException- See Also:
DB.create_function(java.lang.String, org.sqlite.Function, int, int)
-
create_function_utf8
int create_function_utf8(byte[] nameUtf8, Function func, int nArgs, int flags)
-
destroy_function
public int destroy_function(java.lang.String name) throws java.sql.SQLExceptionDescription copied from class:DBDe-registers a user defined function- Specified by:
destroy_functionin classDB- Parameters:
name- Name of the function to de-registered.- Returns:
- Result Codes
- Throws:
java.sql.SQLException- See Also:
DB.destroy_function(java.lang.String)
-
destroy_function_utf8
int destroy_function_utf8(byte[] nameUtf8)
-
create_collation
public int create_collation(java.lang.String name, Collation coll) throws java.sql.SQLExceptionDescription copied from class:DBCreate a user defined collation with given collation name and the collation object.- Specified by:
create_collationin classDB- Parameters:
name- The collation name to be created.coll- SQLite collation object.- Returns:
- Result Codes
- Throws:
java.sql.SQLException- See Also:
DB.create_collation(String, Collation)
-
create_collation_utf8
int create_collation_utf8(byte[] nameUtf8, Collation coll)
-
destroy_collation
public int destroy_collation(java.lang.String name) throws java.sql.SQLExceptionDescription copied from class:DBCreate a user defined collation with given collation name and the collation object.- Specified by:
destroy_collationin classDB- Parameters:
name- The collation name to be created.- Returns:
- Result Codes
- Throws:
java.sql.SQLException- See Also:
DB.destroy_collation(String)
-
destroy_collation_utf8
int destroy_collation_utf8(byte[] nameUtf8)
-
limit
public int limit(int id, int value) throws java.sql.SQLException- Specified by:
limitin classDB- Parameters:
id- The id of the limit.value- The new value of the limit.- Returns:
- The prior value of the limit
- Throws:
java.sql.SQLException- See Also:
- https://www.sqlite.org/c3ref/limit.html
-
nameToUtf8ByteArray
private byte[] nameToUtf8ByteArray(java.lang.String nameType, java.lang.String name) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
backup
public int backup(java.lang.String dbName, java.lang.String destFileName, DB.ProgressObserver observer) throws java.sql.SQLException- Specified by:
backupin classDB- Parameters:
dbName- Database name to be backed up.destFileName- Target backup file name.observer- ProgressObserver object.- Returns:
- Result Codes
- Throws:
java.sql.SQLException- See Also:
DB.backup(java.lang.String, java.lang.String, org.sqlite.core.DB.ProgressObserver)
-
backup
public int backup(java.lang.String dbName, java.lang.String destFileName, DB.ProgressObserver observer, int sleepTimeMillis, int nTimeouts, int pagesPerStep) throws java.sql.SQLException- Specified by:
backupin classDB- 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:
java.sql.SQLException- See Also:
DB.backup(String, String, org.sqlite.core.DB.ProgressObserver, int, int, int)
-
backup
int backup(byte[] dbNameUtf8, byte[] destFileNameUtf8, DB.ProgressObserver observer, int sleepTimeMillis, int nTimeouts, int pagesPerStep) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
restore
public int restore(java.lang.String dbName, java.lang.String sourceFileName, DB.ProgressObserver observer) throws java.sql.SQLException- Specified by:
restorein classDB- Parameters:
dbName- Database name for restoring data.sourceFileName- Source file name.observer- ProgressObserver object.- Returns:
- Result Codes
- Throws:
java.sql.SQLException- See Also:
DB.restore(java.lang.String, java.lang.String, org.sqlite.core.DB.ProgressObserver)
-
restore
public int restore(java.lang.String dbName, java.lang.String sourceFileName, DB.ProgressObserver observer, int sleepTimeMillis, int nTimeouts, int pagesPerStep) throws java.sql.SQLException- Specified by:
restorein classDB- 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:
java.sql.SQLException- See Also:
DB.restore(String, String, ProgressObserver, int, int, int)
-
restore
int restore(byte[] dbNameUtf8, byte[] sourceFileName, DB.ProgressObserver observer, int sleepTimeMillis, int nTimeouts, int pagesPerStep) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
column_metadata
boolean[][] column_metadata(long stmt)
Provides metadata for table columns.- Specified by:
column_metadatain classDB- 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. - See Also:
DB.column_metadata(long)
-
set_commit_listener
void set_commit_listener(boolean enabled)
- Specified by:
set_commit_listenerin classDB
-
set_update_listener
void set_update_listener(boolean enabled)
- Specified by:
set_update_listenerin classDB
-
throwex
static void throwex(java.lang.String msg) throws java.sql.SQLExceptionThrows an SQLException. Called from native code- Parameters:
msg- Message for the SQLException.- Throws:
java.sql.SQLException- the generated SQLException
-
stringToUtf8ByteArray
static byte[] stringToUtf8ByteArray(java.lang.String str)
-
utf8ByteBufferToString
static java.lang.String utf8ByteBufferToString(java.nio.ByteBuffer buffer)
-
register_progress_handler
public void register_progress_handler(int vmCalls, ProgressHandler progressHandler) throws java.sql.SQLExceptionDescription copied from class:DBProgress handler- Specified by:
register_progress_handlerin classDB- Throws:
java.sql.SQLException
-
clear_progress_handler
public void clear_progress_handler() throws java.sql.SQLException- Specified by:
clear_progress_handlerin classDB- Throws:
java.sql.SQLException
-
getBusyHandler
long getBusyHandler()
Getter for native pointer to validate memory is properly cleaned up in unit tests- Returns:
- a native pointer to validate memory is properly cleaned up in unit tests
-
getCommitListener
long getCommitListener()
Getter for native pointer to validate memory is properly cleaned up in unit tests- Returns:
- a native pointer to validate memory is properly cleaned up in unit tests
-
getUpdateListener
long getUpdateListener()
Getter for native pointer to validate memory is properly cleaned up in unit tests- Returns:
- a native pointer to validate memory is properly cleaned up in unit tests
-
getProgressHandler
long getProgressHandler()
Getter for native pointer to validate memory is properly cleaned up in unit tests- Returns:
- a native pointer to validate memory is properly cleaned up in unit tests
-
serialize
public byte[] serialize(java.lang.String schema) throws java.sql.SQLException
-
deserialize
public void deserialize(java.lang.String schema, byte[] buff) throws java.sql.SQLException- Specified by:
deserializein classDB- Throws:
java.sql.SQLException
-
-