public class SQLiteDataSource extends Object implements DataSource
DataSource
API for configuring SQLite database connectionConstructor and Description |
---|
SQLiteDataSource()
Default constructor.
|
SQLiteDataSource(SQLiteConfig config)
Creates a data source based on the provided configuration.
|
Modifier and Type | Method and Description |
---|---|
SQLiteConfig |
getConfig() |
Connection |
getConnection() |
Connection |
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.
|
public SQLiteDataSource()
public SQLiteDataSource(SQLiteConfig config)
config
- The configuration for the data source.public void setConfig(SQLiteConfig config)
config
- The configuration.public SQLiteConfig getConfig()
public void setUrl(String url)
url
- The location of the database file.public String getUrl()
public void setDatabaseName(String databaseName)
databaseName
- The name of the databasepublic String getDatabaseName()
setDatabaseName(String)
public void setSharedCache(boolean enable)
enable
- True to enable; false to disable.public void setLoadExtension(boolean enable)
enable
- True to enable; false to disable.public void setReadOnly(boolean readOnly)
readOnly
- True to enable; false to disable.public void setCacheSize(int numberOfPages)
numberOfPages
- The number of database disk pages.public void setCaseSensitiveLike(boolean enable)
enable
- True to enable; false to disable.public void setCountChanges(boolean enable)
enable
- True to enable; false to disable.public void setDefaultCacheSize(int numberOfPages)
numberOfPages
- The default suggested cache size.public void setEncoding(String encoding)
encoding
- One of "UTF-8", "UTF-16le" (little-endian UTF-16)
or "UTF-16be" (big-endian UTF-16).public void setEnforceForeignKeys(boolean enforce)
enforce
- True to enable; false to disable.public void setFullColumnNames(boolean enable)
enable
- True to enable; false to disable.public void setFullSync(boolean enable)
enable
- True to enable; false to disable.public void setIncrementalVacuum(int numberOfPagesToBeRemoved)
numberOfPagesToBeRemoved
- public void setJournalMode(String mode)
mode
- One of DELETE, TRUNCATE, PERSIST, MEMORY, WAL or OFF.public void setJournalSizeLimit(int limit)
limit
- The default journal size limit is -1 (no limit).public void setLegacyFileFormat(boolean use)
use
- True to turn on; false to turn off.public void setLockingMode(String mode)
mode
- Either NORMAL or EXCLUSIVE.public void setPageSize(int numBytes)
numBytes
- The page size must be a power of two between 512 and 65536 inclusive.public void setMaxPageCount(int numPages)
numPages
- The maximum page count cannot be reduced below the current database size.public void setReadUncommited(boolean useReadUncommitedIsolationMode)
useReadUncommitedIsolationMode
- True to turn on; false to turn off.public void setRecursiveTriggers(boolean enable)
enable
- True to enable; fase to disable.public void setReverseUnorderedSelects(boolean enable)
enable
- True to enable; fase to disable.public void setShortColumnNames(boolean enable)
enable
- True to enable; fase to disable.public void setSynchronous(String mode)
mode
- One of OFF, NORMAL or FULL;public void setTempStore(String storeType)
storeType
- One of "DEFAULT", "FILE", "MEMORY"public void setTempStoreDirectory(String directoryName)
directoryName
- The temporary directory name.public void setTransactionMode(String transactionMode)
transactionMode
- One of DEFFERED, IMMEDIATE or EXCLUSIVE.public void setUserVersion(int version)
version
- public Connection getConnection() throws SQLException
getConnection
in interface DataSource
SQLException
DataSource.getConnection()
public Connection getConnection(String username, String password) throws SQLException
getConnection
in interface DataSource
SQLException
DataSource.getConnection(java.lang.String, java.lang.String)
public PrintWriter getLogWriter() throws SQLException
getLogWriter
in interface CommonDataSource
SQLException
CommonDataSource.getLogWriter()
public int getLoginTimeout() throws SQLException
getLoginTimeout
in interface CommonDataSource
SQLException
CommonDataSource.getLoginTimeout()
public Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger
in interface CommonDataSource
SQLFeatureNotSupportedException
public void setLogWriter(PrintWriter out) throws SQLException
setLogWriter
in interface CommonDataSource
SQLException
CommonDataSource.setLogWriter(java.io.PrintWriter)
public void setLoginTimeout(int seconds) throws SQLException
setLoginTimeout
in interface CommonDataSource
SQLException
CommonDataSource.setLoginTimeout(int)
public boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor
in interface Wrapper
iface
- The class to check.SQLException
public <T> T unwrap(Class<T> iface) throws SQLException
unwrap
in interface Wrapper
iface
- The class to cast to.SQLException
Copyright © 2018. All rights reserved.