Convenience method for calling blob() on the currently selected database.
Convenience method for calling blob() on the currently selected database.
See String, String, long, boolean)
for detailed description.
table name, not null
column name, not null
row id
if true, write access is requested
an instance of SQLiteBlob for incremental reading or writing
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Opens a BLOB for reading or writing.
Opens a BLOB for reading or writing. This method returns an instance of SQLiteBlob
, which can
be used to read or write a single table cell with a BLOB value. After operations are done, the blob should
be disposed.
See SQLite documentation about transactional behavior of the corresponding methods.
database name, or null for the current database
table name, not null
column name, not null
row id
if true, write access is requested
an instance of SQLiteBlob for incremental reading or writing
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Runs SQL and returns formatted result.
Runs SQL and returns formatted result. This method is added for running an SQL from debugger.
SQL to execute
a string containing multiline formatted table with the result
Closes this connection and disposes all related resources.
Closes this connection and disposes all related resources. After dispose() is called, the connection cannot be used and the instance should be forgotten.
Calling this method on an already disposed connection does nothing.
If called from a different thread rather from the thread where the connection was opened, this method does nothing. (It used to attempt connection disposal anyway, but that could lead to JVM crash.)
It is better to call dispose() from a different thread, than not to call it at all.
This method does not throw exception even if SQLite returns an error.
Executes SQL.
Executes SQL. This method is normally used for DDL, transaction control and similar SQL statements.
For querying database and for DML statements with parameters, use #prepare
.
Several statements, delimited by a semicolon, can be executed with a single call.
Do not use this method if your SQL contains non-ASCII characters!
an SQL statement
this connection
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
The finalize() method is used to warn about a non-closed connection being forgotten.
The finalize() method is used to warn about a non-closed connection being forgotten.
Attempts to flush dirty pages in the pager-cache.
Attempts to flush dirty pages in the pager-cache. Dirty pages may exist during a write-transaction. This method may need to acquire extra database locks before it can flush the dirty pages.
SQLiteException
If method cannot acquire extra database locks, or if the call
violates the contract of this class.
Checks if the database is in the auto-commit mode.
Checks if the database is in the auto-commit mode. In auto-commit mode, transaction is ended after execution of every statement.
true if the connection is in auto-commit mode
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
This method returns the number of database rows that were changed or inserted or deleted by the most recently completed SQL statement in this connection.
This method returns the number of database rows that were changed or inserted or deleted by the most recently completed SQL statement in this connection. See SQLite documentation for details.
the number of affected rows, or 0
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Returns the database file.
Returns the database file. This method is thread-safe.
the file that hosts the database, or null if database is in memory
This method returns the error code of the most recently failed operation.
This method returns the error code of the most recently failed operation. However, this method is
rarely needed, as the error code can usually be received from SQLiteException#getErrorCode
.
error code, or 0
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
This method returns the English error message that describes the error returned by #getErrorCode
.
This method returns the English error message that describes the error returned by #getErrorCode
.
error message, or null
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Returns the ROWID of the row, last inserted in this connection (regardless of which statement was used).
Returns the ROWID of the row, last inserted in this connection (regardless of which statement was used). If the table has a column of type INTEGER PRIMARY KEY, then that column contains the ROWID. See SQLite docs.
You can also use "last_insert_rowid()" function in SQL statements following the insert.
the rowid of the last successful insert, or 0 if nothing has been inserted in this connection
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Returns the current limit for the size of a various constructs for the current connection.
Returns the current limit for the size of a various constructs for the current connection.
identifies the class of the constructs to be limited (use { @code SQLITE_LIMIT_*} constants from { @link SQLiteConstants}).
current limit
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Returns the flags that were used to open this connection.
Returns the flags that were used to open this connection.
Flags that were used to open the connection.
Returns meta information about a specific column of a database table.
Returns meta information about a specific column of a database table.
database name or { @code null}
table name
column name
SQLiteColumnMetadata column metadata
SQLiteException
if specified table is actually a view, or if error occurs during this process, or if the requested table or column cannot be found, or if the call violates the contract of this class
This method returns the total number of database rows that were changed or inserted or deleted since this connection was opened.
This method returns the total number of database rows that were changed or inserted or deleted since this connection was opened. See SQLite documentation for details.
the total number of affected rows, or 0
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Initializes backup of the database from this connection to the specified file.
Initializes backup of the database from this connection to the specified file.
This is a convenience method, equivalent to
initializeBackup("main", destinationDbFile, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE)
file to store the backup or null if you want to back up into a in-memory database
an instance of { @link SQLiteBackup}
SQLiteException
if SQLite return an error, or if the call violates the contract of this class
Initializes backup of the database with the given name from the current connection to the specified file.
Initializes backup of the database with the given name from the current connection to the specified file.
This method creates a new SQLite connection to the destination file, opens it with the specified flags and
initializes an instance of SQLiteBackup
for the source and destination connections.
Each successful call
to initializeBackup
must be followed by a call to com.almworks.sqlite4java.SQLiteBackup#dispose
.
The name of the source database is usually "main"
for the main database, or "temp"
for the temporary database. It can also be the name used in the ATTACH clause for an attached database.
The database that will hold the backup in the destination file is always named "main"
.
name of the source database in this connection (usually "main")
file to store the backup or null if you want to back up into a in-memory database
flags for opening the connection to the destination database - see { @link #openV2(int)} for details
a new instance of { @link SQLiteBackup}
SQLiteException
if SQLite return an error, or if the call violates the contract of this class
This method can be called to interrupt a currently long-running SQL statement, causing it to fail with an exception.
This method can be called to interrupt a currently long-running SQL statement, causing it to fail with an exception.
This method is thread-safe.
There are some important implications from using this method, see SQLite docs.
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Checks if the connection has been disposed.
Checks if the connection has been disposed. This method is thread-safe.
true if this connection has been disposed. Disposed connections can't be used for anything.
Checks whether this connection is to an in-memory database.
Checks whether this connection is to an in-memory database. This method is thread-safe.
true if the connection is to the memory database
Tells whether connection is open.
Tells whether connection is open. This method is thread-safe.
true if this connection was successfully opened and has not been disposed
Checks if this connection is read-only.
Checks if this connection is read-only. This is a convenience method for calling
A database can be read-only if:
#openReadonly()
or
#openV2(int)
with SQLiteConstants#SQLITE_OPEN_READONLY
), orThis is a convenience method that calls #isReadOnly(String)
with null
parameter,
checking the status of the main database of this connection.
{ @code true} if the specified database is read-only
SQLiteException
if the requested database name cannot be found
#isReadOnly(String)
Checks if a database accessed through this connection is read-only.
Checks if a database accessed through this connection is read-only.
A database can be read-only if:
#openReadonly()
or
#openV2(int)
with SQLiteConstants#SQLITE_OPEN_READONLY
), ordatabase name, or null for the main database
{ @code true} if the specified database is read-only
SQLiteException
if the requested database name cannot be found
Opens the connection, creating database if needed.
Opens the connection, creating database if needed. See #open(boolean)
for a full description.
this connection
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Opens the connection, optionally creating the database.
Opens the connection, optionally creating the database.
If connection is already open, fails gracefully, allowing connection can be used further.
This method "confines" the connection to the thread in which it has been called. Most of the following method calls to this connection and to its statements should be made only from that thread, otherwise an exception is thrown.
If allowCreate parameter is false, and database file does not exist, method fails with an exception.
if true, database file may be created. For an in-memory database, this parameter must be true.
this connection
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Opens the connection is read-only mode.
Opens the connection is read-only mode. Not applicable for an in-memory database.
See #open(boolean)
for a full description.
this connection
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Opens the connection with the specified flags for the sqlite3_open_v2 method.
Opens the connection with the specified flags for the sqlite3_open_v2 method. The flags SQLITE_OPEN_xxx are defined
in SQLiteConstants
and can be ORed together.
This method is provided for future versions compatibility and for open options not otherwise supported by sqlite4java. Use this method only if other open() methods are not sufficient.
In all other respects, this method works exactly like #open(boolean)
, consult documentation to that method
for details.
integer flags as defined by sqlite3_open_v2 function
this connection
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Convenience method that prepares a cached statement for the given SQL.
Convenience method that prepares a cached statement for the given SQL. See boolean, int)
for details. This variant allows flags to be passed as a parameter.
the SQL statement, not null
The flags parameter use in sqlite3_prepare_v3()
an instance of { @link SQLiteStatement}
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Convenience method that prepares a statement for the given SQL.
Convenience method that prepares a statement for the given SQL. See boolean, int)
for details.
the SQL statement, not null
if true, the statement handle will be cached by the connection
an instance of { @link SQLiteStatement}
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Convenience method that prepares a cached statement for the given SQL.
Convenience method that prepares a cached statement for the given SQL. See boolean, int)
for details.
the SQL statement, not null
an instance of { @link SQLiteStatement}
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Convenience method that prepares a statement for the given String-based SQL.
Convenience method that prepares a statement for the given String-based SQL. See boolean, int)
for details. This variant allows flags to be passed as a parameter.
the SQL statement, not null
if true, the statement handle will be cached by the connection
an instance of { @link SQLiteStatement}
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Convenience method that prepares a statement for the given String-based SQL.
Convenience method that prepares a statement for the given String-based SQL. See boolean, int)
for details.
the SQL statement, not null
if true, the statement handle will be cached by the connection
an instance of { @link SQLiteStatement}
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Convenience method that prepares a cached statement for the given SQL.
Convenience method that prepares a cached statement for the given SQL. See boolean, int)
for details. This variant allows flags to be passed as a parameter.
an SQL statement, not null
an instance of { @link SQLiteStatement}
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Convenience method that prepares a cached statement for the given SQL.
Convenience method that prepares a cached statement for the given SQL. See boolean, int)
for details.
an SQL statement, not null
an instance of { @link SQLiteStatement}
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Prepares an SQL statement.
Prepares an SQL statement. Prepared SQL statement can be used further for putting data into the database and for querying data.
Prepared statements are normally cached by the connection, unless you set cached
parameter
to false. Because parsing SQL is costly, caching should be used in cases where a single SQL can be
executed more than once.
Cached statements are cleared of state before or after they are used.
SQLParts is used to contains the SQL query, yet there are convenience methods that accept String.
Returned statement must be disposed when the calling code is done with it, whether it was cached or not.
the SQL statement, not null
if true, the statement handle will be cached by the connection
A bit array which consists of 0 or more SQLITE_PREPARE_* flags. Note: if statement is already cached, flags will be ignored.
an instance of { @link SQLiteStatement}
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Starts SQL profiling and returns the profiler class.
Starts SQL profiling and returns the profiler class. If profiling is already started, returns the profiler.
This method is thread-safe, in a sense that it can be called from non-session threads. It's not strongly synchronized, so calling it concurrently may result in duplicate profilers.
Only instances of SQLiteStatement created after this method is called will be profiled (whether SQLite statement is cached or not).
the profiler, which will collect stats for all subsequent operations until { @link #stopProfiling} is called.
Attempts to flush dirty pages in the pager-cache.
Attempts to flush dirty pages in the pager-cache. Dirty pages may exist during a write-transaction. This method may attempt to acquire extra database locks before it can flush the dirty pages. On failure, a warning message is logged.
Sets "busy timeout" for this connection.
Sets "busy timeout" for this connection. If timeout is defined, then SQLite will not wait to lock the database for more than the specified number of milliseconds.
By default, the timeout is not set.
number of milliseconds for the busy timeout, or 0 to disable the timeout
this connection
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Allows the size of various constructs for the current connection to be limited.
Allows the size of various constructs for the current connection to be limited.
identifies the class of the constructs to be limited (use { @code SQLITE_LIMIT_*} constants from { @link SQLiteConstants}).
the new limit
previous limit
SQLiteException
if SQLite returns an error, or if the call violates the contract of this class
Sets the frequency of database callbacks during long-running SQL statements.
Sets the frequency of database callbacks during long-running SQL statements. Database callbacks are currently used to check if the statement has been cancelled.
This method is partially thread-safe: it may be called from a non-confining thread before connection is opened. After connection is opened, is should be called from the confining thread and before any statement has been executed.
the number of internal SQLite cycles in between calls to the progress callback (default 1)
Stops the profiling and returns the profiler instance with data.
Stops the profiling and returns the profiler instance with data. If the profiling was not running, returns null.
This method is thread-safe, in a sense that it can be called from non-session threads. It's not strongly synchronized, so calling it concurrently may result in race conditions.
the profiler with collected data, or null
Creates a connection to the database located in the specified file. Database is not opened by the constructor, and the calling thread is insignificant.