org.sqlite

## Class SQLiteDataSource

- java.lang.Object
- - org.sqlite.SQLiteDataSource

All Implemented Interfaces:
  Wrapper, CommonDataSource, DataSource

Direct Known Subclasses:
  SQLiteConnectionPoolDataSource

    public class SQLiteDataSource
    extends Object
    implements DataSource

Provides `DataSource` API for configuring SQLite database connection

Author:
  leo

### Constructor Summary

Constructors
Constructor and Description
`SQLiteDataSource()` Default constructor.
`SQLiteDataSource(SQLiteConfig config)` Creates a data source based on the provided configuration.

### Method Summary

All Methods Instance Methods Concrete Methods
`SQLiteConfig` `getConfig()`
`Connection` `getConnection()`
`SQLiteConnection` `getConnection(String username, String password)`
`String` `getDatabaseName()`
`int` `getLoginTimeout()`
`PrintWriter` `getLogWriter()`
`Logger` `getParentLogger()`
`String` `getUrl()`
`boolean` `isWrapperFor(Class<?> iface)` Determines if this object wraps a given class.
`void` `setCacheSize(int numberOfPages)` Sets the suggested maximum number of database disk pages that SQLite will hold in memory at once per open database file.
`void` `setCaseSensitiveLike(boolean enable)` Enables or disables case sensitivity for the built-in LIKE operator.
`void` `setConfig(SQLiteConfig config)` Sets a data source's configuration.
`void` `setCountChanges(boolean enable)` Enables or disables the count-changes flag.
`void` `setDatabaseName(String databaseName)` Sets the database name.
`void` `setDefaultCacheSize(int numberOfPages)` Sets the default maximum number of database disk pages that SQLite will hold in memory at once per open database file.
`void` `setEncoding(String encoding)` Sets the text encoding used by the main database.
`void` `setEnforceForeignKeys(boolean enforce)` Enables or disables the enforcement of foreign key constraints.
`void` `setFullColumnNames(boolean enable)` Enables or disables the full_column_names flag.
`void` `setFullSync(boolean enable)` Enables or disables the fullfsync flag.
`void` `setIncrementalVacuum(int numberOfPagesToBeRemoved)` Set the incremental_vacuum value that causes up to N pages to be removed from the http://www.sqlite.org/fileformat2.html#freelist.
`void` `setJournalMode(String mode)` Sets the journal mode for databases associated with the current database connection.
`void` `setJournalSizeLimit(int limit)` Sets the limit of the size of rollback-journal and WAL files left in the file-system after transactions or checkpoints.
`void` `setLegacyFileFormat(boolean use)` Set the value of the legacy_file_format flag.
`void` `setLoadExtension(boolean enable)` Enables or disables extension loading.
`void` `setLockingMode(String mode)` Sets the database connection locking-mode.
`void` `setLoginTimeout(int seconds)`
`void` `setLogWriter(PrintWriter out)`
`void` `setMaxPageCount(int numPages)` Set the maximum number of pages in the database file.
`void` `setPageSize(int numBytes)` Set the page size of the database.
`void` `setReadOnly(boolean readOnly)` Sets the database to be opened in read-only mode
`void` `setReadUncommited(boolean useReadUncommitedIsolationMode)` Set READ UNCOMMITTED isolation
`void` `setRecursiveTriggers(boolean enable)` Enables or disables the recursive trigger capability.
`void` `setReverseUnorderedSelects(boolean enable)` Enables or disables the reverse_unordered_selects flag.
`void` `setSharedCache(boolean enable)` Enables or disables the sharing of the database cache and schema data structures between connections to the same database.
`void` `setShortColumnNames(boolean enable)` Enables or disables the short_column_names flag.
`void` `setSynchronous(String mode)` Sets the setting of the "synchronous" flag.
`void` `setTempStore(String storeType)` Set the temp_store type which is used to determine where temporary tables and indices are stored.
`void` `setTempStoreDirectory(String directoryName)` Set the value of the sqlite3_temp_directory global variable, which many operating-system interface backends use to determine where to store temporary tables and indices.
`void` `setTransactionMode(String transactionMode)` Sets the mode that will be used to start transactions for this database.
`void` `setUrl(String url)` Sets the location of the database file.
`void` `setUserVersion(int version)` Sets the value of the user-version.
`<T> T` `unwrap(Class<T> iface)` Casts this object to the given class.

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

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

### Constructor Detail

#### SQLiteDataSource

    public SQLiteDataSource()

Default constructor.

#### SQLiteDataSource

    public SQLiteDataSource(SQLiteConfig config)

Creates a data source based on the provided configuration.

Parameters:
  `config` - The configuration for the data source.

### Method Detail

#### setConfig

    public void setConfig(SQLiteConfig config)

Sets a data source's configuration.

Parameters:
  `config` - The configuration.

#### getConfig

    public SQLiteConfig getConfig()

Returns:
  The configuration for the data source.

#### setUrl

    public void setUrl(String url)

Sets the location of the database file.

Parameters:
  `url` - The location of the database file.

#### getUrl

    public String getUrl()

Returns:
  The location of the database file.

#### setDatabaseName

    public void setDatabaseName(String databaseName)

Sets the database name.

Parameters:
  `databaseName` - The name of the database

#### getDatabaseName

    public String getDatabaseName()

Returns:
  The name of the database if one was set.
See Also:
  `setDatabaseName(String)`

#### setSharedCache

    public void setSharedCache(boolean enable)

Enables or disables the sharing of the database cache and schema data structures between connections to the same database.

Parameters:
  `enable` - True to enable; false to disable.
See Also:
  http://www.sqlite.org/c3ref/enable_shared_cache.html

#### setLoadExtension

    public void setLoadExtension(boolean enable)

Enables or disables extension loading.

Parameters:
  `enable` - True to enable; false to disable.
See Also:
  http://www.sqlite.org/c3ref/load_extension.html

#### setReadOnly

    public void setReadOnly(boolean readOnly)

Sets the database to be opened in read-only mode

Parameters:
  `readOnly` - True to enable; false to disable.
See Also:
  http://www.sqlite.org/c3ref/c_open_autoproxy.html

#### setCacheSize

    public void setCacheSize(int numberOfPages)

Sets the suggested maximum number of database disk pages that SQLite will hold in memory at once per open database file.

Parameters:
  `numberOfPages` - The number of database disk pages.
See Also:
  http://www.sqlite.org/pragma.html#pragma_cache_size

#### setCaseSensitiveLike

    public void setCaseSensitiveLike(boolean enable)

Enables or disables case sensitivity for the built-in LIKE operator.

Parameters:
  `enable` - True to enable; false to disable.
See Also:
  http://www.sqlite.org/compile.html#case_sensitive_like

#### setCountChanges

    public void setCountChanges(boolean enable)

Enables or disables the count-changes flag. When enabled INSERT, UPDATE and DELETE statements return the number of rows they modified.

Parameters:
  `enable` - True to enable; false to disable.
See Also:
  http://www.sqlite.org/pragma.html#pragma_count_changes

#### setDefaultCacheSize

    public void setDefaultCacheSize(int numberOfPages)

Sets the default maximum number of database disk pages that SQLite will hold in memory at once per open database file.

Parameters:
  `numberOfPages` - The default suggested cache size.
See Also:
  http://www.sqlite.org/pragma.html#pragma_cache_size

#### setEncoding

    public void setEncoding(String encoding)

Sets the text encoding used by the main database.

Parameters:
  `encoding` - One of "UTF-8", "UTF-16le" (little-endian UTF-16) or "UTF-16be" (big-endian UTF-16).
See Also:
  http://www.sqlite.org/pragma.html#pragma_encoding

#### setEnforceForeignKeys

    public void setEnforceForeignKeys(boolean enforce)

Enables or disables the enforcement of foreign key constraints.

Parameters:
  `enforce` - True to enable; false to disable.
See Also:
  http://www.sqlite.org/pragma.html#pragma_foreign_keys

#### setFullColumnNames

    public void setFullColumnNames(boolean enable)

Enables or disables the full_column_names flag. This flag together with the short_column_names flag determine the way SQLite assigns names to result columns of SELECT statements.

Parameters:
  `enable` - True to enable; false to disable.
See Also:
  http://www.sqlite.org/pragma.html#pragma_full_column_names

#### setFullSync

    public void setFullSync(boolean enable)

Enables or disables the fullfsync flag. This flag determines whether or not the F_FULLFSYNC syncing method is used on systems that support it.

Parameters:
  `enable` - True to enable; false to disable.
See Also:
  http://www.sqlite.org/pragma.html#pragma_fullfsync

#### setIncrementalVacuum

    public void setIncrementalVacuum(int numberOfPagesToBeRemoved)

Set the incremental_vacuum value that causes up to N pages to be removed from the http://www.sqlite.org/fileformat2.html#freelist.

Parameters:
  `numberOfPagesToBeRemoved` -
See Also:
  http://www.sqlite.org/pragma.html#pragma_incremental_vacuum

#### setJournalMode

    public void setJournalMode(String mode)

Sets the journal mode for databases associated with the current database connection.

Parameters:
  `mode` - One of DELETE, TRUNCATE, PERSIST, MEMORY, WAL or OFF.
See Also:
  http://www.sqlite.org/pragma.html#pragma_journal_mode

#### setJournalSizeLimit

    public void setJournalSizeLimit(int limit)

Sets the limit of the size of rollback-journal and WAL files left in the file-system after transactions or checkpoints.

Parameters:
  `limit` - The default journal size limit is -1 (no limit).
See Also:
  http://www.sqlite.org/pragma.html#pragma_journal_size_limit

#### setLegacyFileFormat

    public void setLegacyFileFormat(boolean use)

Set the value of the legacy_file_format flag. When this flag is on, new databases are created in a file format that is readable and writable by all versions of SQLite going back to 3.0.0. When the flag is off, new databases are created using the latest file format which might not be readable or writable by versions of SQLite prior to 3.3.0.

Parameters:
  `use` - True to turn on; false to turn off.
See Also:
  http://www.sqlite.org/pragma.html#pragma_legacy_file_format

#### setLockingMode

    public void setLockingMode(String mode)

Sets the database connection locking-mode.

Parameters:
  `mode` - Either NORMAL or EXCLUSIVE.
See Also:
  http://www.sqlite.org/pragma.html#pragma_locking_mode

#### setPageSize

    public void setPageSize(int numBytes)

Set the page size of the database.

Parameters:
  `numBytes` - The page size must be a power of two between 512 and 65536 inclusive.
See Also:
  http://www.sqlite.org/pragma.html#pragma_page_size

#### setMaxPageCount

    public void setMaxPageCount(int numPages)

Set the maximum number of pages in the database file.

Parameters:
  `numPages` - The maximum page count cannot be reduced below the current database size.
See Also:
  http://www.sqlite.org/pragma.html#pragma_max_page_count

#### setReadUncommited

    public void setReadUncommited(boolean useReadUncommitedIsolationMode)

Set READ UNCOMMITTED isolation

Parameters:
  `useReadUncommitedIsolationMode` - True to turn on; false to turn off.
See Also:
  http://www.sqlite.org/pragma.html#pragma_read_uncommitted

#### setRecursiveTriggers

    public void setRecursiveTriggers(boolean enable)

Enables or disables the recursive trigger capability. Changing the recursive_triggers setting affects the execution of all statements prepared using the database connection, including those prepared before the setting was changed.

Parameters:
  `enable` - True to enable; fase to disable.
See Also:
  http://www.sqlite.org/pragma.html#pragma_recursive_triggers

#### setReverseUnorderedSelects

    public void setReverseUnorderedSelects(boolean enable)

Enables or disables the reverse_unordered_selects flag. When enabled it causes SELECT statements without an ORDER BY clause to emit their results in the reverse order of what they normally would.

Parameters:
  `enable` - True to enable; fase to disable.
See Also:
  http://www.sqlite.org/pragma.html#pragma_reverse_unordered_selects

#### setShortColumnNames

    public void setShortColumnNames(boolean enable)

Enables or disables the short_column_names flag. This flag affects the way SQLite names columns of data returned by SELECT statements.

Parameters:
  `enable` - True to enable; fase to disable.
See Also:
  http://www.sqlite.org/pragma.html#pragma_short_column_names, http://www.sqlite.org/pragma.html#pragma_fullfsync

#### setSynchronous

    public void setSynchronous(String mode)

Sets the setting of the "synchronous" flag.

Parameters:
  `mode` - One of OFF, NORMAL or FULL;
See Also:
  http://www.sqlite.org/pragma.html#pragma_synchronous

#### setTempStore

    public void setTempStore(String storeType)

Set the temp_store type which is used to determine where temporary tables and indices are stored.

Parameters:
  `storeType` - One of "DEFAULT", "FILE", "MEMORY"
See Also:
  http://www.sqlite.org/pragma.html#pragma_temp_store

#### setTempStoreDirectory

    public void setTempStoreDirectory(String directoryName)

Set the value of the sqlite3_temp_directory global variable, which many operating-system interface backends use to determine where to store temporary tables and indices.

Parameters:
  `directoryName` - The temporary directory name.
See Also:
  http://www.sqlite.org/pragma.html#pragma_temp_store_directory

#### setTransactionMode

    public void setTransactionMode(String transactionMode)

Sets the mode that will be used to start transactions for this database.

Parameters:
  `transactionMode` - One of DEFFERED, IMMEDIATE or EXCLUSIVE.
See Also:
  http://www.sqlite.org/lang_transaction.html

#### setUserVersion

    public void setUserVersion(int version)

Sets the value of the user-version. It is a big-endian 32-bit signed integer stored in the database header at offset 60.

Parameters:
  `version` -
See Also:
  http://www.sqlite.org/pragma.html#pragma_schema_version

#### getConnection

    public Connection getConnection()
                             throws SQLException

Specified by:
  `getConnection` in interface `DataSource`
Throws:
  `SQLException`
See Also:
  `DataSource.getConnection()`

#### getConnection

    public SQLiteConnection getConnection(String username,
                                          String password)
                                   throws SQLException

Specified by:
  `getConnection` in interface `DataSource`
Throws:
  `SQLException`
See Also:
  `DataSource.getConnection(java.lang.String, java.lang.String)`

#### getLogWriter

    public PrintWriter getLogWriter()
                             throws SQLException

Specified by:
  `getLogWriter` in interface `CommonDataSource`
Throws:
  `SQLException`
See Also:
  `CommonDataSource.getLogWriter()`

#### getLoginTimeout

    public int getLoginTimeout()
                        throws SQLException

Specified by:
  `getLoginTimeout` in interface `CommonDataSource`
Throws:
  `SQLException`
See Also:
  `CommonDataSource.getLoginTimeout()`

#### getParentLogger

    public Logger getParentLogger()
                           throws SQLFeatureNotSupportedException

Specified by:
  `getParentLogger` in interface `CommonDataSource`
Throws:
  `SQLFeatureNotSupportedException`

#### setLogWriter

    public void setLogWriter(PrintWriter out)
                      throws SQLException

Specified by:
  `setLogWriter` in interface `CommonDataSource`
Throws:
  `SQLException`
See Also:
  `CommonDataSource.setLogWriter(java.io.PrintWriter)`

#### setLoginTimeout

    public void setLoginTimeout(int seconds)
                         throws SQLException

Specified by:
  `setLoginTimeout` in interface `CommonDataSource`
Throws:
  `SQLException`
See Also:
  `CommonDataSource.setLoginTimeout(int)`

#### isWrapperFor

    public boolean isWrapperFor(Class<?> iface)
                         throws SQLException

Determines if this object wraps a given class.

Specified by:
  `isWrapperFor` in interface `Wrapper`
Parameters:
  `iface` - The class to check.
Returns:
  True if it is an instance of the current class; false otherwise.
Throws:
  `SQLException`

#### unwrap

    public <T> T unwrap(Class<T> iface)
                 throws SQLException

Casts this object to the given class.

Specified by:
  `unwrap` in interface `Wrapper`
Parameters:
  `iface` - The class to cast to.
Returns:
  The casted class.
Throws:
  `SQLException`