de.mguennewig.pobjects.jdbc
Class SQLiteContainer

java.lang.Object
  extended by de.mguennewig.pobjects.AbstractContainer
      extended by de.mguennewig.pobjects.jdbc.JdbcContainer
          extended by de.mguennewig.pobjects.jdbc.SQLiteContainer
All Implemented Interfaces:
Container

public class SQLiteContainer
extends JdbcContainer

Container implementation for SQLite3 databases.

This implementation uses a type table to work around the limitations of SQLite INHERITS support.

As SQLite3 does not support FOREIGN KEY constraints they are simulated over the extensive TRIGGER support.

Further limitations of SQLite:

Note that different JDBC drivers use a slightly different syntax to specify a database:

SQLite/JDBC driver by Christian Werner <chw@ch-werner.de> requires:
The database name must start with a slash, followed by an absolute or relative path. To specify a memory databse use /:memory.
SQLiteJDBC driver by David Crawshow <david@zentus.com> requires:
The database name is either an absolute or relative path. To specify a memory database use an empty database name.

Author:
Michael Günnewig
See Also:
SQLite

Nested Class Summary
static class SQLiteContainer.SQLiteEvalContext
           
 
Field Summary
 
Fields inherited from interface de.mguennewig.pobjects.Container
SUPPORTS_BOOLEAN, SUPPORTS_INHERITS, SUPPORTS_JOIN, SUPPORTS_LIMIT_OFFSET, SUPPORTS_ORACLE_JOIN, SUPPORTS_SQL99_JOIN, USE_ARRAY_FOR_LOB, USE_STREAM_TO_INSERT_LOB
 
Constructor Summary
SQLiteContainer(java.sql.Connection conn, PObjDictionary dict, java.lang.String schema)
          Creates a container with a specified connection to a DBMS.
SQLiteContainer(PObjDictionary dict, java.lang.String schema)
          Creates a container without a connection to any DBMS.
SQLiteContainer(java.lang.String hostname, java.lang.Integer port, java.lang.String database, java.lang.String username, java.lang.String password, PObjDictionary dict, java.lang.String schema)
          Creates a container that opens a connection to the specified database.
 
Method Summary
 int getCapabilities()
          Returns the capabilities of the DBMS.
 java.lang.String getConnectURL(java.lang.String hostname, java.lang.Integer port, java.lang.String database)
          
 java.lang.String getSequenceCurrentValue(Sequence seq)
          Returns the current value of the given sequence.
 java.lang.String getSequenceNextValue(Sequence seq)
          Returns a new value of the given sequence.
 java.lang.String insertObject(PObject obj)
          Inserts the given object into the database.
 EvalContext newEvalContext(int numColumns)
          
 
Methods inherited from class de.mguennewig.pobjects.jdbc.JdbcContainer
addArguments, addParameter, beginTransaction, close, commitTransaction, deleteAll, deleteAll, deleteObject, deleteRecord, getConnection, getConnectProperties, getObject, insertRecord, mapClassDeclToPClassId, mapPClassIdToClassDecl, newQuery, prepareStatement, prepareStatement, reset, retrieveData, rollbackTransaction, setConnection, updateObject
 
Methods inherited from class de.mguennewig.pobjects.AbstractContainer
createObject, deleteAll, getClassDecl, getClassDecls, getData, getDictionary, getObject, getQualifiedName, getSchema, getTableExpr, isStrictMode, makePersistent, newQuery, newQuery, newQuery, newQuery, newQuery, newQuery, newQuery, newQuery, notifyChange, setStrictMode, storeAll, supportsBoolean, supportsInherits, supportsLimitOffset, supportsOracleJoin, supportsSQL99Join, useArrayForLob, useStreamToInsertLob
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLiteContainer

public SQLiteContainer(PObjDictionary dict,
                       java.lang.String schema)
Creates a container without a connection to any DBMS.


SQLiteContainer

public SQLiteContainer(java.lang.String hostname,
                       java.lang.Integer port,
                       java.lang.String database,
                       java.lang.String username,
                       java.lang.String password,
                       PObjDictionary dict,
                       java.lang.String schema)
                throws java.sql.SQLException
Creates a container that opens a connection to the specified database.

NOTE: Auto-commitment will be turned off which is normally turned on for JDBC.

Parameters:
hostname - ignored as not suitable for SQLite.
port - ignored as not suitable for SQLite.
database - The filename of the database.
username - ignored as not suitable for SQLite.
password - ignored as not suitable for SQLite.
dict -
schema - ignored as SQLite does not support schemas.
Throws:
java.sql.SQLException - if no connection to the database can be opened, or an error occurred during initialization
See Also:
JdbcContainer.initializeConnection()

SQLiteContainer

public SQLiteContainer(java.sql.Connection conn,
                       PObjDictionary dict,
                       java.lang.String schema)
                throws java.sql.SQLException
Creates a container with a specified connection to a DBMS.

NOTE: Auto-commitment will be turned off which is normally turned on for JDBC.

Throws:
java.sql.SQLException - if any database error occurs during initialization.
See Also:
JdbcContainer.initializeConnection()
Method Detail

getConnectURL

public java.lang.String getConnectURL(java.lang.String hostname,
                                      java.lang.Integer port,
                                      java.lang.String database)

Specified by:
getConnectURL in class JdbcContainer

getCapabilities

public int getCapabilities()
Returns the capabilities of the DBMS.

All SQLite JDBC drivers support Container.USE_ARRAY_FOR_LOB, but Container.USE_STREAM_TO_INSERT_LOB is only available for Christian Werner SQLite/JDBC driver implementation.

See Also:
"The SUPPORTS_* constants."

getSequenceCurrentValue

public java.lang.String getSequenceCurrentValue(Sequence seq)
Returns the current value of the given sequence.


getSequenceNextValue

public java.lang.String getSequenceNextValue(Sequence seq)
Returns a new value of the given sequence.


insertObject

public java.lang.String insertObject(PObject obj)
                              throws PObjConstraintException,
                                     PObjSQLException
Inserts the given object into the database.

Throws:
PObjConstraintException - if a database constraint will be violated.
PObjSQLException - if any other database error occurs.

newEvalContext

public EvalContext newEvalContext(int numColumns)

Specified by:
newEvalContext in interface Container
Overrides:
newEvalContext in class JdbcContainer