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 boolean
autoCommit
protected static java.util.Map<SQLiteConfig.TransactionMode,java.lang.String>
beginCommandMap
private int
busyTimeout
SQLiteConfig.DateClass
dateClass
FastDateFormat
dateFormat
long
dateMultiplier
SQLiteConfig.DatePrecision
datePrecision
java.lang.String
dateStringFormat
protected DB
db
private java.lang.String
fileName
protected CoreDatabaseMetaData
meta
protected int
openModeFlags
private static java.util.Set<java.lang.String>
pragmaSet
private static java.lang.String
RESOURCE_NAME_PREFIX
protected int
transactionIsolation
protected SQLiteConfig.TransactionMode
transactionMode
private java.lang.String
url
-
Constructor Summary
Constructors Modifier Constructor Description protected
CoreConnection(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 void
checkCursor(int rst, int rsc, int rsh)
Checks whether the type, concurrency, and holdability settings for aResultSet
are supported by the SQLite interface.protected void
checkOpen()
Whether an SQLite library interface to the database has been established.void
close()
DB
db()
private java.lang.String
extractPragmasFromFilename(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.File
extractResource(java.net.URL resourceAddr)
Returns a file name from the given resource address.void
finalize()
int
getBusyTimeout()
java.lang.String
getDriverVersion()
java.lang.String
libversion()
private void
open(int openModeFlags, int busyTimeout)
Opens a connection to the database using an SQLite library.void
setBusyTimeout(int milliseconds)
Sets the timeout value for the connection.protected void
setTransactionMode(SQLiteConfig.TransactionMode mode)
Sets the mode that will be used to start transactions on this connection.java.lang.String
url()
-
-
-
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.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:
java.sql.SQLException
-
open
private void open(int openModeFlags, int busyTimeout) throws java.sql.SQLException
Opens 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.IOException
Returns 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.SQLException
Sets 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.SQLException
Whether 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.SQLException
Checks whether the type, concurrency, and holdability settings for aResultSet
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:
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:
finalize
in 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()
-
-