|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opensubsystems.core.persist.db.DatabaseImpl
public abstract class DatabaseImpl
Base class for all classes encapsulating various differences in behaviour for different database. Most likely one project will use only one database therefore this class contains factory methods to instantiate and return default instance of database even though it still allows multiple instances of database to exist since all attributes are non-static.
| Field Summary | |
|---|---|
protected boolean |
m_bDatabaseSchemaInitialized
Flag signaling that the database schema was initialized; |
protected boolean |
m_bDatabaseStarted
Flag if database was started. |
protected boolean |
m_bDatabaseStartInProgress
Flag signaling that the database start is in progress. |
protected VersionedDatabaseSchema |
m_vdsSchema
Database schema for this database. |
static int |
MAX_SAFE_LENGTH
Number specifying maximal safe length for members within the IN () clause Because there is limitation for sql statement length (in sap db is default 64 kb) and in() expression can contain lot of members. |
| Constructor Summary | |
|---|---|
protected |
DatabaseImpl()
Default constructor. |
| Method Summary | |
|---|---|
void |
add(java.lang.Class clsSchema)
Add new schema to the database schema by specifying the generic schema class or interface. |
void |
add(DatabaseSchema dsSchema)
Add new schema to the database schema. |
abstract void |
createDatabaseInstance()
Method for creating database instance. |
protected abstract void |
createUser(java.sql.Connection cntAdminDBConnection)
Create database user which will be used by connection pool to access the database. |
protected java.sql.Connection |
getAdminConnection(boolean bAutoCommit)
Get connection with administration priviledges. |
java.lang.String |
getConnectionTestStatement()
Get very efficient parameterless SQL statement which can be used to test connection validity. |
static Database |
getInstance()
Get the default database instance. |
static Database |
getInstanceIfStarted()
Get the default database instance if it was started otherwise return null. |
int |
getSelectListResultSetConcurrency()
This method returns default result set concurrency which should be used to load lists of items from the result set efficiently. |
int |
getSelectListResultSetType()
This method returns default result set type which should be used to load lists of items from the result set efficiently. |
int |
getTransactionIsolation(int iTransactionIsolation)
Different databases have different bugs about what they support so this method will take the desired transaction isolation level and convert it to the one supported by database. |
boolean |
hasAbsolutePositioningSupport()
Find out if database (driver) allows us to call methods such as absolute() or last() for retrieved result sets. |
boolean |
hasSelectListRangeSupport()
Find out if database allows us to support rows limitation. |
boolean |
isStarted()
Test if the database is started. |
boolean |
preferCountToLast()
Find out if when trying to find out size of the result set we should use rather count(*)/count(1)/count(id) instead of using hasAbsolutePositioningSupport. |
static void |
setInstance(Database dbDatabase)
Set default database instance. |
void |
start()
Start the database. |
abstract void |
startDatabaseServer()
Method for starting database instance. |
void |
stop()
Stop the database. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.opensubsystems.core.persist.db.Database |
|---|
getCurrentTimestampFunctionCall, getDatabaseType, getDatabaseTypeIdentifier, getSQLAnalyzeFunctionCall, getSQLCountFunctionCall, insertAndFetchGeneratedValues, isCallableStatement, updatedAndFetchGeneratedValues |
| Field Detail |
|---|
public static final int MAX_SAFE_LENGTH
protected boolean m_bDatabaseSchemaInitialized
protected boolean m_bDatabaseStartInProgress
protected boolean m_bDatabaseStarted
protected VersionedDatabaseSchema m_vdsSchema
| Constructor Detail |
|---|
protected DatabaseImpl()
throws OSSException
OSSException - - problem creating connection factory| Method Detail |
|---|
public static Database getInstance()
throws OSSException
OSSException - - problem accessing the database
public static Database getInstanceIfStarted()
throws OSSException
OSSException - - problem accessing the databasepublic static void setInstance(Database dbDatabase)
dbDatabase - - new default database instancegetInstance()
public void start()
throws OSSException
start in interface DatabaseOSSException - - database cannot be started.
public void stop()
throws OSSException
stop in interface DatabaseOSSException - - problems stopping the databasepublic boolean isStarted()
isStarted in interface Database
public abstract void startDatabaseServer()
throws OSSException
OSSException - - problem starting the server
public abstract void createDatabaseInstance()
throws OSSException
OSSException - - problem creating the database instance
public void add(DatabaseSchema dsSchema)
throws OSSException
add in interface DatabasedsSchema - - schema to add to the database
OSSException - - database cannot be started.
public void add(java.lang.Class clsSchema)
throws OSSException
add in interface DatabaseclsSchema - - class representing schema to add to the database
OSSException - - database cannot be started.public java.lang.String getConnectionTestStatement()
getConnectionTestStatement in interface Databasepublic int getTransactionIsolation(int iTransactionIsolation)
getTransactionIsolation in interface DatabaseiTransactionIsolation - - desired transaction isolation level
public int getSelectListResultSetType()
getSelectListResultSetType in interface Databasepublic boolean hasAbsolutePositioningSupport()
hasAbsolutePositioningSupport in interface Databasepublic boolean preferCountToLast()
preferCountToLast in interface Databasepublic boolean hasSelectListRangeSupport()
hasSelectListRangeSupport in interface Databasepublic int getSelectListResultSetConcurrency()
getSelectListResultSetConcurrency in interface Database
protected abstract void createUser(java.sql.Connection cntAdminDBConnection)
throws OSSException
cntAdminDBConnection - - connection with rights to create users
OSSException - - cannot create user
protected java.sql.Connection getAdminConnection(boolean bAutoCommit)
throws OSSException
bAutoCommit - - desired autocommit setting for the connection
OSSException - - problem connecting to database
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||