Package org.sqlite.core
Class CoreConnection
- java.lang.Object
-
- org.sqlite.core.CoreConnection
-
- Direct Known Subclasses:
JDBC3Connection
public abstract class CoreConnection extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanautoCommitprotected static java.util.Map<SQLiteConfig.TransactionMode,java.lang.String>beginCommandMapprivate intbusyTimeoutSQLiteConfig.DateClassdateClassFastDateFormatdateFormatlongdateMultiplierSQLiteConfig.DatePrecisiondatePrecisionjava.lang.StringdateStringFormatprotected DBdbprivate java.lang.StringfileNameprotected CoreDatabaseMetaDatametaprotected intopenModeFlagsprivate static java.util.Set<java.lang.String>pragmaSetprivate static java.lang.StringRESOURCE_NAME_PREFIXprotected inttransactionIsolationprotected SQLiteConfig.TransactionModetransactionModeprivate java.lang.Stringurl
-
Constructor Summary
Constructors Modifier Constructor Description protectedCoreConnection(java.lang.String url, java.lang.String fileName, java.util.Properties prop)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckCursor(int rst, int rsc, int rsh)Checks whether the type, concurrency, and holdability settings for aResultSetare supported by the SQLite interface.protected voidcheckOpen()Whether an SQLite library interface to the database has been established.voidclose()DBdb()private java.lang.StringextractPragmasFromFilename(java.lang.String filename, java.util.Properties prop)Extracts PRAGMA values from the filename and sets them into the Properties object which will be used to build the SQLConfig.private java.io.FileextractResource(java.net.URL resourceAddr)Returns a file name from the given resource address.voidfinalize()intgetBusyTimeout()java.lang.StringgetDriverVersion()java.lang.Stringlibversion()private voidopen(int openModeFlags, int busyTimeout)Opens a connection to the database using an SQLite library.voidsetBusyTimeout(int milliseconds)Sets the timeout value for the connection.protected voidsetTransactionMode(SQLiteConfig.TransactionMode mode)Sets the mode that will be used to start transactions on this connection.java.lang.Stringurl()
-
-
-
Field Detail
-
RESOURCE_NAME_PREFIX
private static final java.lang.String RESOURCE_NAME_PREFIX
- See Also:
- Constant Field Values
-
url
private final java.lang.String url
-
fileName
private java.lang.String fileName
-
db
protected DB db
-
meta
protected CoreDatabaseMetaData meta
-
autoCommit
protected boolean autoCommit
-
transactionIsolation
protected int transactionIsolation
-
busyTimeout
private int busyTimeout
-
openModeFlags
protected final int openModeFlags
-
transactionMode
protected SQLiteConfig.TransactionMode transactionMode
-
beginCommandMap
protected static final java.util.Map<SQLiteConfig.TransactionMode,java.lang.String> beginCommandMap
-
pragmaSet
private static final java.util.Set<java.lang.String> pragmaSet
-
dateClass
public final SQLiteConfig.DateClass dateClass
-
datePrecision
public final SQLiteConfig.DatePrecision datePrecision
-
dateMultiplier
public final long dateMultiplier
-
dateFormat
public final FastDateFormat dateFormat
-
dateStringFormat
public final java.lang.String dateStringFormat
-
-
Method Detail
-
extractPragmasFromFilename
private java.lang.String extractPragmasFromFilename(java.lang.String filename, java.util.Properties prop) throws java.sql.SQLExceptionExtracts 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:
java.sql.SQLException
-
open
private void open(int openModeFlags, int busyTimeout) throws java.sql.SQLExceptionOpens a connection to the database using an SQLite library.- Parameters:
openModeFlags- Flags for file open operations.- Throws:
java.sql.SQLException- See Also:
- http://www.sqlite.org/c3ref/c_open_autoproxy.html
-
extractResource
private java.io.File extractResource(java.net.URL resourceAddr) throws java.io.IOExceptionReturns a file name from the given resource address.- Parameters:
resourceAddr- The resource address.- Returns:
- The extracted file name.
- Throws:
java.io.IOException
-
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 milliseconds) throws java.sql.SQLExceptionSets the timeout value for the connection. A timeout value less than or equal to zero turns off all busy handlers.- Parameters:
milliseconds- The timeout value in milliseconds.- Throws:
java.sql.SQLException- See Also:
- http://www.sqlite.org/c3ref/busy_timeout.html
-
url
public java.lang.String url()
- Returns:
- Where the database is located.
-
libversion
public java.lang.String libversion() throws java.sql.SQLException- Returns:
- Compile-time library version numbers.
- Throws:
java.sql.SQLException- See Also:
- http://www.sqlite.org/c3ref/c_source_id.html
-
db
public DB db()
- Returns:
- The class interface to SQLite.
-
checkOpen
protected void checkOpen() throws java.sql.SQLExceptionWhether an SQLite library interface to the database has been established.- Throws:
java.sql.SQLException
-
checkCursor
protected void checkCursor(int rst, int rsc, int rsh) throws java.sql.SQLExceptionChecks whether the type, concurrency, and holdability settings for aResultSetare 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:
java.sql.SQLException
- type:
-
setTransactionMode
protected void setTransactionMode(SQLiteConfig.TransactionMode mode)
Sets the mode that will be used to start transactions on this connection.- Parameters:
mode- One ofSQLiteConfig.TransactionMode- See Also:
- http://www.sqlite.org/lang_transaction.html
-
getDriverVersion
public java.lang.String getDriverVersion()
- Returns:
- One of "native" or "unloaded".
-
finalize
public void finalize() throws java.sql.SQLException- Overrides:
finalizein classjava.lang.Object- Throws:
java.sql.SQLException- See Also:
Object.finalize()
-
close
public void close() throws java.sql.SQLException- Throws:
java.sql.SQLException- See Also:
Connection.close()
-
-