Package org.sqlite

## Class SQLiteConnection

- java.lang.Object
- - org.sqlite.SQLiteConnection

All Implemented Interfaces:
  `AutoCloseable`, `Connection`, `Wrapper`

Direct Known Subclasses:
  `JDBC3Connection`

    public abstract class SQLiteConnection
    extends Object
    implements Connection

### Field Summary

### Fields inherited from interface java.sql.Connection

`TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE`

### Constructor Summary

Constructors
`SQLiteConnection​(String url, String fileName)` Constructor to create a connection to a database at the given location.
`SQLiteConnection​(String url, String fileName, Properties prop)` Constructor to create a pre-configured connection to a database at the given location.
`SQLiteConnection​(DB db)` Connection constructor for reusing an existing DB handle

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `abort​(Executor executor)`
`void` `addCommitListener​(SQLiteCommitListener listener)` Add a listener for DB commit/rollback events, see https://www.sqlite.org/c3ref/commit_hook.html
`void` `addUpdateListener​(SQLiteUpdateListener listener)` Add a listener for DB update events, see https://www.sqlite.org/c3ref/update_hook.html
`protected void` `checkCursor​(int rst, int rsc, int rsh)` Checks whether the type, concurrency, and holdability settings for a `ResultSet` are supported by the SQLite interface.
`protected void` `checkOpen()` Whether an SQLite library interface to the database has been established.
`void` `close()`
`void` `commit()`
`protected static String` `extractPragmasFromFilename​(String url, String filename, Properties prop)` Extracts PRAGMA values from the filename and sets them into the Properties object which will be used to build the SQLConfig.
`boolean` `getAutoCommit()`
`int` `getBusyTimeout()`
`SQLiteConnectionConfig` `getConnectionConfig()`
`SQLiteConfig.TransactionMode` `getCurrentTransactionMode()`
`DB` `getDatabase()`
`void` `getLimit​(SQLiteLimits limit)`
`DatabaseMetaData` `getMetaData()`
`int` `getNetworkTimeout()`
`String` `getSchema()`
`CoreDatabaseMetaData` `getSQLiteDatabaseMetaData()`
`int` `getTransactionIsolation()`
`String` `getUrl()`
`boolean` `isClosed()`
`boolean` `isFirstStatementExecuted()`
`String` `libversion()`
`void` `removeCommitListener​(SQLiteCommitListener listener)` Remove a listener registered for DB commit/rollback events.
`void` `removeUpdateListener​(SQLiteUpdateListener listener)` Remove a listener registered for DB update events.
`void` `rollback()`
`void` `setAutoCommit​(boolean ac)`
`void` `setBusyTimeout​(int timeoutMillis)` Sets the timeout value for the connection.
`void` `setCurrentTransactionMode​(SQLiteConfig.TransactionMode currentTransactionMode)`
`void` `setFirstStatementExecuted​(boolean firstStatementExecuted)`
`void` `setLimit​(SQLiteLimits limit, int value)`
`void` `setNetworkTimeout​(Executor executor, int milliseconds)`
`void` `setSchema​(String schema)`
`void` `setTransactionIsolation​(int level)`
`protected void` `setTransactionMode​(SQLiteConfig.TransactionMode mode)` Sets the mode that will be used to start transactions on this connection.
`protected String` `transactionPrefix()`

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

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

### Methods inherited from interface java.sql.Connection

`beginRequest, clearWarnings, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, endRequest, getCatalog, getClientInfo, getClientInfo, getHoldability, getTypeMap, getWarnings, isReadOnly, isValid, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, setCatalog, setClientInfo, setClientInfo, setHoldability, setReadOnly, setSavepoint, setSavepoint, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid, setTypeMap`

### Methods inherited from interface java.sql.Wrapper

`isWrapperFor, unwrap`

### Constructor Detail

#### SQLiteConnection

    public SQLiteConnection​(DB db)

Connection constructor for reusing an existing DB handle

Parameters:
  `db` -

#### SQLiteConnection

    public SQLiteConnection​(String url,
                            String fileName)
                     throws SQLException

Constructor to create a connection to a database at the given location.

Parameters:
  `url` - The location of the database.
  `fileName` - The database.
Throws:
  `SQLException`

#### SQLiteConnection

    public SQLiteConnection​(String url,
                            String fileName,
                            Properties prop)
                     throws SQLException

Constructor to create a pre-configured connection to a database at the given location.

Parameters:
  `url` - The location of the database file.
  `fileName` - The database.
  `prop` - The configurations to apply.
Throws:
  `SQLException`

### Method Detail

#### getCurrentTransactionMode

    public SQLiteConfig.TransactionMode getCurrentTransactionMode()

#### setCurrentTransactionMode

    public void setCurrentTransactionMode​(SQLiteConfig.TransactionMode currentTransactionMode)

#### setFirstStatementExecuted

    public void setFirstStatementExecuted​(boolean firstStatementExecuted)

#### isFirstStatementExecuted

    public boolean isFirstStatementExecuted()

#### getConnectionConfig

    public SQLiteConnectionConfig getConnectionConfig()

#### getSQLiteDatabaseMetaData

    public CoreDatabaseMetaData getSQLiteDatabaseMetaData()
                                                   throws SQLException

Throws:
  `SQLException`

#### getMetaData

    public DatabaseMetaData getMetaData()
                                 throws SQLException

Specified by:
  `getMetaData` in interface `Connection`
Throws:
  `SQLException`

#### getUrl

    public String getUrl()

#### setSchema

    public void setSchema​(String schema)
                   throws SQLException

Specified by:
  `setSchema` in interface `Connection`
Throws:
  `SQLException`

#### getSchema

    public String getSchema()
                     throws SQLException

Specified by:
  `getSchema` in interface `Connection`
Throws:
  `SQLException`

#### abort

    public void abort​(Executor executor)
               throws SQLException

Specified by:
  `abort` in interface `Connection`
Throws:
  `SQLException`

#### setNetworkTimeout

    public void setNetworkTimeout​(Executor executor,
                                  int milliseconds)
                           throws SQLException

Specified by:
  `setNetworkTimeout` in interface `Connection`
Throws:
  `SQLException`

#### getNetworkTimeout

    public int getNetworkTimeout()
                          throws SQLException

Specified by:
  `getNetworkTimeout` in interface `Connection`
Throws:
  `SQLException`

#### checkCursor

    protected void checkCursor​(int rst,
                               int rsc,
                               int rsh)
                        throws SQLException

Checks whether the type, concurrency, and holdability settings for a `ResultSet` are supported by the SQLite interface. Supported settings are:

- type: `ResultSet.TYPE_FORWARD_ONLY`
- concurrency: `ResultSet.CONCUR_READ_ONLY`)
- holdability: `ResultSet.CLOSE_CURSORS_AT_COMMIT`

Parameters:
  `rst` - the type setting.
  `rsc` - the concurrency setting.
  `rsh` - the holdability setting.
Throws:
  `SQLException`

#### setTransactionMode

    protected void setTransactionMode​(SQLiteConfig.TransactionMode mode)

Sets the mode that will be used to start transactions on this connection.

Parameters:
  `mode` - One of `SQLiteConfig.TransactionMode`
See Also:
  http://www.sqlite.org/lang_transaction.html

#### getTransactionIsolation

    public int getTransactionIsolation()

Specified by:
  `getTransactionIsolation` in interface `Connection`
See Also:
  `Connection.getTransactionIsolation()`

#### setTransactionIsolation

    public void setTransactionIsolation​(int level)
                                 throws SQLException

Specified by:
  `setTransactionIsolation` in interface `Connection`
Throws:
  `SQLException`
See Also:
  `Connection.setTransactionIsolation(int)`

#### getDatabase

    public DB getDatabase()

#### getAutoCommit

    public boolean getAutoCommit()
                          throws SQLException

Specified by:
  `getAutoCommit` in interface `Connection`
Throws:
  `SQLException`
See Also:
  `Connection.getAutoCommit()`

#### setAutoCommit

    public void setAutoCommit​(boolean ac)
                       throws SQLException

Specified by:
  `setAutoCommit` in interface `Connection`
Throws:
  `SQLException`
See Also:
  `Connection.setAutoCommit(boolean)`

#### getBusyTimeout

    public int getBusyTimeout()

Returns:
  The busy timeout value for the connection.
See Also:
  http://www.sqlite.org/c3ref/busy_timeout.html

#### setBusyTimeout

    public void setBusyTimeout​(int timeoutMillis)
                        throws SQLException

Sets the timeout value for the connection. A timeout value less than or equal to zero turns off all busy handlers.

Parameters:
  `timeoutMillis` - The timeout value in milliseconds.
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/busy_timeout.html

#### setLimit

    public void setLimit​(SQLiteLimits limit,
                         int value)
                  throws SQLException

Throws:
  `SQLException`

#### getLimit

    public void getLimit​(SQLiteLimits limit)
                  throws SQLException

Throws:
  `SQLException`

#### isClosed

    public boolean isClosed()
                     throws SQLException

Specified by:
  `isClosed` in interface `Connection`
Throws:
  `SQLException`

#### close

    public void close()
               throws SQLException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Connection`
Throws:
  `SQLException`
See Also:
  `Connection.close()`

#### checkOpen

    protected void checkOpen()
                      throws SQLException

Whether an SQLite library interface to the database has been established.

Throws:
  `SQLException`

#### libversion

    public String libversion()
                      throws SQLException

Returns:
  Compile-time library version numbers.
Throws:
  `SQLException`
See Also:
  http://www.sqlite.org/c3ref/c_source_id.html

#### commit

    public void commit()
                throws SQLException

Specified by:
  `commit` in interface `Connection`
Throws:
  `SQLException`
See Also:
  `Connection.commit()`

#### rollback

    public void rollback()
                  throws SQLException

Specified by:
  `rollback` in interface `Connection`
Throws:
  `SQLException`
See Also:
  `Connection.rollback()`

#### addUpdateListener

    public void addUpdateListener​(SQLiteUpdateListener listener)

Add a listener for DB update events, see https://www.sqlite.org/c3ref/update_hook.html

Parameters:
  `listener` - The listener to receive update events

#### removeUpdateListener

    public void removeUpdateListener​(SQLiteUpdateListener listener)

Remove a listener registered for DB update events.

Parameters:
  `listener` - The listener to no longer receive update events

#### addCommitListener

    public void addCommitListener​(SQLiteCommitListener listener)

Add a listener for DB commit/rollback events, see https://www.sqlite.org/c3ref/commit_hook.html

Parameters:
  `listener` - The listener to receive commit events

#### removeCommitListener

    public void removeCommitListener​(SQLiteCommitListener listener)

Remove a listener registered for DB commit/rollback events.

Parameters:
  `listener` - The listener to no longer receive commit/rollback events.

#### extractPragmasFromFilename

    protected static String extractPragmasFromFilename​(String url,
                                                       String filename,
                                                       Properties prop)
                                                throws SQLException

Extracts PRAGMA values from the filename and sets them into the Properties object which will be used to build the SQLConfig. The sanitized filename is returned.

Parameters:
  `filename` -
  `prop` -
Returns:
  a PRAGMA-sanitized filename
Throws:
  `SQLException`

#### transactionPrefix

    protected String transactionPrefix()