com.almworks.sqlite4java
Class SQLiteConnection

java.lang.Object
  extended by com.almworks.sqlite4java.SQLiteConnection

public final class SQLiteConnection
extends java.lang.Object

SQLiteConnection is a single connection to sqlite database. It wraps the sqlite3* database handle from SQLite C Interface.

Unless otherwise specified, methods are confined to the thread that was used to open the connection. This means that an exception will be thrown if you try to access the method from a different thread.

SQLiteConnection should be expicitly closed before the object is disposed. Failing to do so may result in unpredictable behavior from SQLite.

Once closed with dispose(), the connection cannot be reused and the instance should be forgotten.

Several connections to the same database can be opened by creating several instances of SQLiteConnection.

SQLiteConnection tracks all statements it had prepared. When connection is disposed, it first tries to dispose all prepared statements. If there's an active transaction, it is rolled back.

Author:
Igor Sereda
See Also:
SQLiteStatement, sqlite3*

Field Summary
static java.lang.String DEFAULT_DB_NAME
           
 
Constructor Summary
SQLiteConnection()
          Creates a connection to an in-memory temporary database.
SQLiteConnection(java.io.File dbfile)
          Creates a connection to the database located in the specified file.
 
Method Summary
 SQLiteBlob blob(java.lang.String table, java.lang.String column, long rowid, boolean writeAccess)
          Convenience method for calling blob() on the currently selected database.
 SQLiteBlob blob(java.lang.String dbname, java.lang.String table, java.lang.String column, long rowid, boolean writeAccess)
          Opens a BLOB for reading or writing.
 SQLiteLongArray createArray()
          Creates a virtual table within the current session, to represent an array of long values (functionality provided by test_intarray module from SQLite sources).
 SQLiteLongArray createArray(java.lang.String name, boolean cached)
          Creates a virtual table within the current session, to represent an array of long values (functionality provided by test_intarray module from SQLite sources).
 java.lang.String debug(java.lang.String sql)
          Runs SQL and returns formatted result.
 void dispose()
          Closes this connection and disposes all related resources.
 SQLiteConnection exec(java.lang.String sql)
          Executes SQL.
protected  void finalize()
          The finalize() method is used to warn about a non-closed connection being forgotten.
 boolean getAutoCommit()
          Checks if the database is in the auto-commit mode.
 int getChanges()
          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.
 java.io.File getDatabaseFile()
          Returns the database file.
 int getErrorCode()
          This method returns the error code of the most recently failed operation.
 java.lang.String getErrorMessage()
          This method returns the English error message that describes the error returned by getErrorCode().
 long getLastInsertId()
          Returns the ROWID of the row, last inserted in this connection (regardless of which statement was used).
 int getLimit(int id)
          Returns the current limit for the size of a various constructs for the current connection.
 int getOpenFlags()
          Returns the flags that were used to open this connection.
 SQLiteColumnMetadata getTableColumnMetadata(java.lang.String dbName, java.lang.String tableName, java.lang.String columnName)
          Returns meta information about a specific column of a database table.
 int getTotalChanges()
          This method returns the total number of database rows that were changed or inserted or deleted since this connection was opened.
 SQLiteBackup initializeBackup(java.io.File destinationDbFile)
           Initializes backup of the database from this connection to the specified file.
 SQLiteBackup initializeBackup(java.lang.String sourceDbName, java.io.File destinationDbFile, int flags)
           Initializes backup of the database with the given name from the current connection to the specified file.
 void interrupt()
          This method can be called to interrupt a currently long-running SQL statement, causing it to fail with an exception.
 boolean isDisposed()
          Checks if the connection has been disposed.
 boolean isMemoryDatabase()
          Checks whether this connection is to an in-memory database.
 boolean isOpen()
          Tells whether connection is open.
 boolean isReadOnly()
          Checks if this connection is read-only.
 boolean isReadOnly(java.lang.String dbName)
          Checks if a database accessed through this connection is read-only.
 void loadExtension(java.io.File extensionFile)
          Loads an SQLite extension library using default extension entry point.
 void loadExtension(java.io.File extensionFile, java.lang.String entryPoint)
          Loads an SQLite extension library.
 SQLiteConnection open()
          Opens the connection, creating database if needed.
 SQLiteConnection open(boolean allowCreate)
          Opens the connection, optionally creating the database.
 SQLiteConnection openReadonly()
          Opens the connection is read-only mode.
 SQLiteConnection openV2(int flags)
          Opens the connection with the specified flags for the sqlite3_open_v2 method.
 SQLiteStatement prepare(SQLParts sql)
          Convenience method that prepares a cached statement for the given SQL.
 SQLiteStatement prepare(SQLParts sql, boolean cached)
          Prepares an SQL statement.
 SQLiteStatement prepare(java.lang.String sql)
          Convenience method that prepares a cached statement for the given SQL.
 SQLiteStatement prepare(java.lang.String sql, boolean cached)
          Convenience method that prepares a statement for the given String-based SQL.
 SQLiteProfiler profile()
          Starts SQL profiling and returns the profiler class.
 SQLiteConnection setBusyTimeout(long millis)
          Sets "busy timeout" for this connection.
 void setExtensionLoadingEnabled(boolean enabled)
          Enables or disables SQLite extension loading for this connection.
 int setLimit(int id, int newVal)
          Allows the size of various constructs for the current connection to be limited.
 void setStepsPerCallback(int stepsPerCallback)
          Sets the frequency of database callbacks during long-running SQL statements.
 SQLiteProfiler stopProfiling()
          Stops the profiling and returns the profiler instance with data.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_DB_NAME

public static final java.lang.String DEFAULT_DB_NAME
See Also:
Constant Field Values
Constructor Detail

SQLiteConnection

public SQLiteConnection(java.io.File dbfile)
Creates a connection to the database located in the specified file. Database is not opened by the constructor, and the calling thread is insignificant.

Parameters:
dbfile - database file, or null to create an in-memory database

SQLiteConnection

public SQLiteConnection()
Creates a connection to an in-memory temporary database. Database is not opened by the constructor, and the calling thread is insignificant.

See Also:
SQLiteConnection(java.io.File)
Method Detail

getDatabaseFile

public java.io.File getDatabaseFile()
Returns the database file. This method is thread-safe.

Returns:
the file that hosts the database, or null if database is in memory

isMemoryDatabase

public boolean isMemoryDatabase()
Checks whether this connection is to an in-memory database. This method is thread-safe.

Returns:
true if the connection is to the memory database

setStepsPerCallback

public void setStepsPerCallback(int stepsPerCallback)
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.

Parameters:
stepsPerCallback - the number of internal SQLite cycles in between calls to the progress callback (default 1)
See Also:
sqlite3_progress_callback

setLimit

public int setLimit(int id,
                    int newVal)
             throws SQLiteException
Allows the size of various constructs for the current connection to be limited.

Parameters:
id - identifies the class of the constructs to be limited (use SQLITE_LIMIT_* constants from SQLiteConstants).
newVal - the new limit
Returns:
previous limit
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_limit

getLimit

public int getLimit(int id)
             throws SQLiteException
Returns the current limit for the size of a various constructs for the current connection.

Parameters:
id - identifies the class of the constructs to be limited (use SQLITE_LIMIT_* constants from SQLiteConstants).
Returns:
current limit
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_limit

open

public SQLiteConnection open(boolean allowCreate)
                      throws SQLiteException
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.

Parameters:
allowCreate - if true, database file may be created. For an in-memory database, this parameter must be true.
Returns:
this connection
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_open_v2

open

public SQLiteConnection open()
                      throws SQLiteException
Opens the connection, creating database if needed. See open(boolean) for a full description.

Returns:
this connection
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class

openReadonly

public SQLiteConnection openReadonly()
                              throws SQLiteException
Opens the connection is read-only mode. Not applicable for an in-memory database. See open(boolean) for a full description.

Returns:
this connection
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class

openV2

public SQLiteConnection openV2(int flags)
                        throws SQLiteException
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.

Parameters:
flags - integer flags as defined by sqlite3_open_v2 function
Returns:
this connection
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_open_v2

isOpen

public boolean isOpen()
Tells whether connection is open. This method is thread-safe.

Returns:
true if this connection was successfully opened and has not been disposed

isDisposed

public boolean isDisposed()
Checks if the connection has been disposed. This method is thread-safe.

Returns:
true if this connection has been disposed. Disposed connections can't be used for anything.

isReadOnly

public boolean isReadOnly(java.lang.String dbName)
                   throws SQLiteException

Checks if a database accessed through this connection is read-only.

A database can be read-only if:

Parameters:
dbName - database name, or null for the main database
Returns:
true if the specified database is read-only
Throws:
SQLiteException - if the requested database name cannot be found
See Also:
sqlite3_db_readonly

isReadOnly

public boolean isReadOnly()
                   throws SQLiteException

Checks if this connection is read-only. This is a convenience method for calling

A database can be read-only if:

This is a convenience method that calls isReadOnly(String) with null parameter, checking the status of the main database of this connection.

Returns:
true if the specified database is read-only
Throws:
SQLiteException - if the requested database name cannot be found
See Also:
isReadOnly(String), sqlite3_db_readonly

getOpenFlags

public int getOpenFlags()
Returns the flags that were used to open this connection.

Returns:
Flags that were used to open the connection.

dispose

public void dispose()
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.

See Also:
sqlite3_close

exec

public SQLiteConnection exec(java.lang.String sql)
                      throws SQLiteException
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(com.almworks.sqlite4java.SQLParts, boolean).

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!

Parameters:
sql - an SQL statement
Returns:
this connection
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_exec

getTableColumnMetadata

public SQLiteColumnMetadata getTableColumnMetadata(java.lang.String dbName,
                                                   java.lang.String tableName,
                                                   java.lang.String columnName)
                                            throws SQLiteException
Returns meta information about a specific column of a database table.

Parameters:
dbName - database name or null
tableName - table name
columnName - column name
Returns:
SQLiteColumnMetadata column metadata
Throws:
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
See Also:
sqlite3_table_column_metadata

prepare

public SQLiteStatement prepare(SQLParts sql,
                               boolean cached)
                        throws SQLiteException
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.

Parameters:
sql - the SQL statement, not null
cached - if true, the statement handle will be cached by the connection
Returns:
an instance of SQLiteStatement
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_prepare_v2

prepare

public SQLiteStatement prepare(java.lang.String sql)
                        throws SQLiteException
Convenience method that prepares a cached statement for the given SQL. See prepare(SQLParts, boolean) for details.

Parameters:
sql - an SQL statement, not null
Returns:
an instance of SQLiteStatement
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class

prepare

public SQLiteStatement prepare(java.lang.String sql,
                               boolean cached)
                        throws SQLiteException
Convenience method that prepares a statement for the given String-based SQL. See prepare(SQLParts, boolean) for details.

Parameters:
sql - the SQL statement, not null
cached - if true, the statement handle will be cached by the connection
Returns:
an instance of SQLiteStatement
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class

prepare

public SQLiteStatement prepare(SQLParts sql)
                        throws SQLiteException
Convenience method that prepares a cached statement for the given SQL. See prepare(SQLParts, boolean) for details.

Parameters:
sql - the SQL statement, not null
Returns:
an instance of SQLiteStatement
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class

blob

public SQLiteBlob blob(java.lang.String dbname,
                       java.lang.String table,
                       java.lang.String column,
                       long rowid,
                       boolean writeAccess)
                throws SQLiteException
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.

Parameters:
dbname - database name, or null for the current database
table - table name, not null
column - column name, not null
rowid - row id
writeAccess - if true, write access is requested
Returns:
an instance of SQLiteBlob for incremental reading or writing
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_blob_open

blob

public SQLiteBlob blob(java.lang.String table,
                       java.lang.String column,
                       long rowid,
                       boolean writeAccess)
                throws SQLiteException
Convenience method for calling blob() on the currently selected database. See blob(String, String, String, long, boolean) for detailed description.

Parameters:
table - table name, not null
column - column name, not null
rowid - row id
writeAccess - if true, write access is requested
Returns:
an instance of SQLiteBlob for incremental reading or writing
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class

setBusyTimeout

public SQLiteConnection setBusyTimeout(long millis)
                                throws SQLiteException
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.

Parameters:
millis - number of milliseconds for the busy timeout, or 0 to disable the timeout
Returns:
this connection
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_busy_timeout

getAutoCommit

public boolean getAutoCommit()
                      throws SQLiteException
Checks if the database is in the auto-commit mode. In auto-commit mode, transaction is ended after execution of every statement.

Returns:
true if the connection is in auto-commit mode
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_get_autocommit

getLastInsertId

public long getLastInsertId()
                     throws SQLiteException
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.

Returns:
the rowid of the last successful insert, or 0 if nothing has been inserted in this connection
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_last_insert_rowid

getChanges

public int getChanges()
               throws SQLiteException
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.

Returns:
the number of affected rows, or 0
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_changes

getTotalChanges

public int getTotalChanges()
                    throws SQLiteException
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.

Returns:
the total number of affected rows, or 0
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_total_changes

interrupt

public void interrupt()
               throws SQLiteException
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.

Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_interrupt

getErrorCode

public int getErrorCode()
                 throws SQLiteException
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().

Returns:
error code, or 0
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_errcode, sqlite3_extended_errcode

getErrorMessage

public java.lang.String getErrorMessage()
                                 throws SQLiteException
This method returns the English error message that describes the error returned by getErrorCode().

Returns:
error message, or null
Throws:
SQLiteException - if SQLite returns an error, or if the call violates the contract of this class
See Also:
sqlite3_errmsg

profile

public SQLiteProfiler profile()
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).

Returns:
the profiler, which will collect stats for all subsequent operations until stopProfiling() is called.

stopProfiling

public SQLiteProfiler stopProfiling()
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.

Returns:
the profiler with collected data, or null

createArray

public SQLiteLongArray createArray(java.lang.String name,
                                   boolean cached)
                            throws SQLiteException
Creates a virtual table within the current session, to represent an array of long values (functionality provided by test_intarray module from SQLite sources). After SQLiteLongArray is created, it can be bound consequently several times to a long[], and the virtual table can be used in any SQL. This provides means to make queries with array parameters. For example:
 long[] itemIds = ...;
 SQLiteLongArray array = connection.createArray();
 SQLiteStatement st = connection.prepare("SELECT * FROM items WHERE itemId IN " + array.getName());
 array.bind(itemIds);
 while (st.step()) {
   // read values
 }
 st.dispose();
 array.dispose();
 

The array contents is bound using SQLiteLongArray.bind(long[], int, int, boolean, boolean) methods. Binding an array is not a transactional operation; it does not start or stop a transaction, and contents of the array is not affected by ROLLBACK.

You can execute any SQL using array's name (SQLiteLongArray.getName()) as the table name. The actual table is a VIRTUAL TABLE, residing in TEMP database. (Because of that, temp database may be created on disk - you can change that using PRAGMA TEMP_STORE.)

It is possible to execute an SQL that contains several virtual array tables.

Note that the virtual array table does not have a primary key (bound values may have duplicates and come in random order), so be careful about performance.

SQLiteLongArray are cached by the SQLiteConnection, unless cached parameter is set to false. When cached SQLiteLongArray is disposed, it is kept by the connection for further reuse. When a non-cached SQLiteLongArray is disposed, its table is deleted from the TEMP database.

Caution: It's possible to use DROP TABLE on the array virtual table; doing that will make SQL statements that use the table invalid.

Parameters:
name - the name of the table, must be a correct SQL table name, and contains only ASCII characters. If null, a temporary name will be provided automatically (can be later retrieved via SQLiteLongArray.getName().
cached - if true, then a cached array will be used, thus reducing the number of virtual tables and schema changes. If cached is true and a name is given and there's no free array with that name, a new array will be created. If cached is true and name is null, then any free array will be allocated.
Returns:
an instance of SQLiteLongArray, wrapping an empty (unbound) virtual array table
Throws:
SQLiteException - if name is already in use, or if other problem happens
See Also:
test_intarray.h

createArray

public SQLiteLongArray createArray()
                            throws SQLiteException
Creates a virtual table within the current session, to represent an array of long values (functionality provided by test_intarray module from SQLite sources). After SQLiteLongArray is created, it can be bound consequently several times to a long[], and the virtual table can be used in any SQL.

This is a convenience method that creates an array with an arbitrary name and cached by the connection, equal to call to createArray(null, true). See createArray(String, boolean) for details.

Returns:
an instance of SQLiteLongArray, wrapping an empty (unbound) virtual array table
Throws:
SQLiteException - in case any problem is reported by SQLite, or general contract is broken

initializeBackup

public SQLiteBackup initializeBackup(java.lang.String sourceDbName,
                                     java.io.File destinationDbFile,
                                     int flags)
                              throws SQLiteException

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 SQLiteBackup.dispose(boolean).

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".

Parameters:
sourceDbName - name of the source database in this connection (usually "main")
destinationDbFile - file to store the backup or null if you want to back up into a in-memory database
flags - flags for opening the connection to the destination database - see openV2(int) for details
Returns:
a new instance of SQLiteBackup
Throws:
SQLiteException - if SQLite return an error, or if the call violates the contract of this class
See Also:
sqlite3_backup_init

initializeBackup

public SQLiteBackup initializeBackup(java.io.File destinationDbFile)
                              throws SQLiteException

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)

Parameters:
destinationDbFile - file to store the backup or null if you want to back up into a in-memory database
Returns:
an instance of SQLiteBackup
Throws:
SQLiteException - if SQLite return an error, or if the call violates the contract of this class

setExtensionLoadingEnabled

public void setExtensionLoadingEnabled(boolean enabled)
                                throws SQLiteException
Enables or disables SQLite extension loading for this connection. By default, extension loading is disabled.

Parameters:
enabled - if true, extensions can be loaded via loadExtension(java.io.File, java.lang.String) function
Throws:
SQLiteException - if extension loading flag cannot be changed
See Also:
enable_load_extension

loadExtension

public void loadExtension(java.io.File extensionFile,
                          java.lang.String entryPoint)
                   throws SQLiteException
Loads an SQLite extension library. Extension loading must be enabled with setExtensionLoadingEnabled(boolean) prior to calling this method.

Parameters:
extensionFile - extension library, not null
entryPoint - entry point function; if null, defaults to "sqlite3_extension_init"
Throws:
SQLiteException - if extension can't be loaded
See Also:
load_extension

loadExtension

public void loadExtension(java.io.File extensionFile)
                   throws SQLiteException
Loads an SQLite extension library using default extension entry point. Extension loading must be enabled with setExtensionLoadingEnabled(boolean) prior to calling this method.

Parameters:
extensionFile - extension library, not null
Throws:
SQLiteException - if extension can't be loaded
See Also:
load_extension

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

finalize

protected void finalize()
                 throws java.lang.Throwable
The finalize() method is used to warn about a non-closed connection being forgotten.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

debug

public java.lang.String debug(java.lang.String sql)
Runs SQL and returns formatted result. This method is added for running an SQL from debugger.

Parameters:
sql - SQL to execute
Returns:
a string containing multiline formatted table with the result