org.opensubsystems.core.persist.db.driver
Class DatabaseTestSchema

java.lang.Object
  extended by org.opensubsystems.core.persist.db.DatabaseSchemaImpl
      extended by org.opensubsystems.core.persist.db.ModifiableDatabaseSchemaImpl
          extended by org.opensubsystems.core.persist.db.driver.DatabaseTestSchema
All Implemented Interfaces:
org.opensubsystems.core.persist.db.DatabaseOperations, org.opensubsystems.core.persist.db.DatabaseSchema, org.opensubsystems.core.persist.db.ModifiableDatabaseSchema
Direct Known Subclasses:
DB2DatabaseTestSchema, HsqlDBDatabaseTestSchema, MSSQLDatabaseTestSchema, MySQLDatabaseTestSchema, OracleDatabaseTestSchema, PostgreSQLDatabaseTestSchema, SapDBDatabaseTestSchema, SybaseDatabaseTestSchema

public abstract class DatabaseTestSchema
extends org.opensubsystems.core.persist.db.ModifiableDatabaseSchemaImpl

This class encapsulates details about creation and upgrade of database schema required to test database driver functionality. This database schema already contains some database specific tables and thats why it was declared abstract.

Version:
$Id: DatabaseTestSchema.java,v 1.23 2007/01/10 05:16:59 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
Initial revision

Field Summary
static java.lang.String DBTEST_SCHEMA_NAME
          Name identifies this schema in the database.
static int DBTEST_SCHEMA_VERSION
          Version of this schema in the database.
static java.util.Map TABLE_NAMES
          List of table names belonging to this schema.
 
Fields inherited from class org.opensubsystems.core.persist.db.ModifiableDatabaseSchemaImpl
m_mapModifiableTableNames
 
Fields inherited from class org.opensubsystems.core.persist.db.DatabaseSchemaImpl
DATABASE_SCHEMA_PREFIX, DATABASE_SCHEMA_PREFIX_DEFAULT, m_arrDependentSchemas, m_bIsInDomain, m_iSchemaVersion, m_strSchemaName, NL
 
Fields inherited from interface org.opensubsystems.core.persist.db.DatabaseOperations
DBOP_DELETE, DBOP_INSERT, DBOP_SELECT, DBOP_UPDATE
 
Constructor Summary
DatabaseTestSchema()
          Default constructor.
 
Method Summary
 void create(java.sql.Connection cntDBConnection, java.lang.String strUserName)
          
 void createDataSource(org.opensubsystems.core.persist.db.DatabaseConnectionFactory dbConnectionFactory, java.lang.String strDataSourceName, java.lang.String strDatabaseDriver, java.lang.String strDatabaseURL, java.lang.String strUserName, java.lang.String strUserPassword)
          Create datasource with specified parameters.
abstract  void createTestUser(java.sql.Connection cntAdminDBConnection, java.lang.String strDatabaseURL, java.lang.String strUserName, java.lang.String strUserPassword)
          Create test user in the specified database.
abstract  void dropTestUser(java.sql.Connection cntAdminDBConnection, java.lang.String strDatabaseURL, java.lang.String strUserName)
          Drop test user in the specified database.
abstract  int[] executeInsertGeneratedKey2(java.sql.Connection dbConnection, java.lang.String strValue)
          Execute another query to insert to table with generated keys which guarantees return
abstract  int[] executeInsertRow(java.sql.Connection dbConnection, java.lang.String strValue)
          Execute another query to insert to table.
abstract  int executeUpdateTestValue(java.sql.Connection dbConnection, java.lang.String strOldValue, java.lang.String strNewValue)
          Execute query to update test value using stored procedure without parameters
abstract  java.lang.String getInsertGeneratedKey()
          Query to insert to table with generated keys is database specific.
 java.lang.String getInsertSelectQuery()
          Returns insert-select query
 java.lang.String getSelectExceptQuery()
          Returns select except query
 java.lang.String getSelectExceptUnionQuery()
          Returns select-except-union query
 java.lang.String getSelectExistQuery()
          Returns select-exist query
 
Methods inherited from class org.opensubsystems.core.persist.db.ModifiableDatabaseSchemaImpl
deleteRelatedData, getModifiableTableNames, handleSQLException
 
Methods inherited from class org.opensubsystems.core.persist.db.DatabaseSchemaImpl
getDependentSchemas, getJoinFromWhere, getName, getOwnerColumnNames, getSchemaPrefix, getVersion, isExistingIndex, isInDomain, upgrade, upgradeView
 
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.DatabaseSchema
getDependentSchemas, getName, getVersion, isInDomain, upgrade
 

Field Detail

DBTEST_SCHEMA_NAME

public static final java.lang.String DBTEST_SCHEMA_NAME
Name identifies this schema in the database.

See Also:
Constant Field Values

DBTEST_SCHEMA_VERSION

public static final int DBTEST_SCHEMA_VERSION
Version of this schema in the database.

See Also:
Constant Field Values

TABLE_NAMES

public static final java.util.Map TABLE_NAMES
List of table names belonging to this schema.

Constructor Detail

DatabaseTestSchema

public DatabaseTestSchema()
                   throws org.opensubsystems.core.error.OSSException
Default constructor.

Throws:
org.opensubsystems.core.error.OSSException - - error occured.
Method Detail

create

public void create(java.sql.Connection cntDBConnection,
                   java.lang.String strUserName)
            throws java.sql.SQLException

Throws:
java.sql.SQLException

getInsertSelectQuery

public java.lang.String getInsertSelectQuery()
Returns insert-select query

Returns:
String - SQL query for insert-select .

getSelectExceptQuery

public java.lang.String getSelectExceptQuery()
Returns select except query

Returns:
String - SQL query for select-except.

getSelectExceptUnionQuery

public java.lang.String getSelectExceptUnionQuery()
Returns select-except-union query

Returns:
String - SQL query for select-except-union.

getSelectExistQuery

public java.lang.String getSelectExistQuery()
Returns select-exist query

Returns:
String - SQL query for select-exist.

getInsertGeneratedKey

public abstract java.lang.String getInsertGeneratedKey()
Query to insert to table with generated keys is database specific.

Returns:
String - SQL query to insert to table with generated keys.

executeInsertGeneratedKey2

public abstract int[] executeInsertGeneratedKey2(java.sql.Connection dbConnection,
                                                 java.lang.String strValue)
                                          throws java.sql.SQLException
Execute another query to insert to table with generated keys which guarantees return

Parameters:
dbConnection - - database connection
strValue - - value to insert
Returns:
int[] - index 0 - how many records were inserted - index 1 - the value of generated key
Throws:
java.sql.SQLException - - error during insert execute

executeInsertRow

public abstract int[] executeInsertRow(java.sql.Connection dbConnection,
                                       java.lang.String strValue)
                                throws java.sql.SQLException
Execute another query to insert to table. There will be test if calling of stored procedure will return number of inserted rows.

Parameters:
dbConnection - - database connection
strValue - - value to insert
Returns:
int[] - index 0 - how many records were inserted - index 1 - the value of inserted records retrieved from stored procedure
Throws:
java.sql.SQLException - - error during insert execute

executeUpdateTestValue

public abstract int executeUpdateTestValue(java.sql.Connection dbConnection,
                                           java.lang.String strOldValue,
                                           java.lang.String strNewValue)
                                    throws java.sql.SQLException
Execute query to update test value using stored procedure without parameters

Parameters:
dbConnection - - database connection
strOldValue - - old value to be updated
strNewValue - - new value for update
Returns:
int - number of updated records
Throws:
java.sql.SQLException - - error during insert execute

createDataSource

public void createDataSource(org.opensubsystems.core.persist.db.DatabaseConnectionFactory dbConnectionFactory,
                             java.lang.String strDataSourceName,
                             java.lang.String strDatabaseDriver,
                             java.lang.String strDatabaseURL,
                             java.lang.String strUserName,
                             java.lang.String strUserPassword)
                      throws org.opensubsystems.core.error.OSSDatabaseAccessException
Create datasource with specified parameters.

Parameters:
dbConnectionFactory - - database connection factory
strDataSourceName - - name of the data source
strDatabaseDriver - - database driver
strDatabaseURL - - database URL
strUserName - - name of the user that will be created
strUserPassword - - user password
Throws:
org.opensubsystems.core.error.OSSDatabaseAccessException - - error during data source creation

createTestUser

public abstract void createTestUser(java.sql.Connection cntAdminDBConnection,
                                    java.lang.String strDatabaseURL,
                                    java.lang.String strUserName,
                                    java.lang.String strUserPassword)
                             throws java.sql.SQLException
Create test user in the specified database.

Parameters:
cntAdminDBConnection - - database connection
strDatabaseURL - - database URL
strUserName - - name of the user that will be created
strUserPassword - - user password
Throws:
java.sql.SQLException - - error during user creation

dropTestUser

public abstract void dropTestUser(java.sql.Connection cntAdminDBConnection,
                                  java.lang.String strDatabaseURL,
                                  java.lang.String strUserName)
                           throws java.sql.SQLException
Drop test user in the specified database.

Parameters:
cntAdminDBConnection - - database connection
strDatabaseURL - - database URL
strUserName - - name of the user that will be created
Throws:
java.sql.SQLException - - error during user deletion


Copyright © 2003 - 2006 OpenSubsystems s.r.o.