com.ptc.windchill.upgrade.modeldiff
Class Db

java.lang.Object
  extended bycom.ptc.windchill.upgrade.modeldiff.Db

class Db
extends Object

This package private class is an attempt to isolate database vendor peculiarities.


Field Summary
(package private) static String BLOBTSNAME
           
(package private) static String CHUNKSIZE
           
private static Connection connection_
           
private static String DB_DIR
           
private static String DB_PASSWORD
           
private static String DB_SERVICE_DRIVER
           
private static String DB_SERVICE_URL
           
(package private) static String DB_USER
           
private static boolean doesDataStoreSupportFbis_
           
private static boolean doesDataStoreSupportFbisIsSet_
           
private static boolean doesSqlGeneratorSupportFbis_
           
private static String HUGE
           
(package private) static String HUGETABLESIZE
           
private static String JDBC_DRIVER
           
private static String LARGE
           
(package private) static String LARGETABLESIZE
           
(package private) static String LINE_SEPARATOR
           
private static String MEDIUM
           
(package private) static String MEDIUMTABLESIZE
           
(package private) static int MOD_COLUMN
           
(package private) static int NEW_COLUMN
           
(package private) static boolean NORMALIZE_INDEX_COLUMN_NAMES
           
(package private) static int OLD_COLUMN
           
(package private) static String SERVICE_NAME
           
private static String SMALL
           
(package private) static String SMALLTABLESIZE
           
private static SQLGenerator sqlGenerator_
           
private static String TINY
           
(package private) static String TINYTABLESIZE
           
 
Constructor Summary
(package private) Db()
           
 
Method Summary
(package private) static void closeResultSet(ResultSet result_set)
           
(package private) static void closeStatement(Statement statement)
           
(package private) static Connection connectToDatabase()
          Connect to the database using info in Windchill's properties files.
(package private) static Statement createStatement()
           
(package private) static String createView(String class_name, DatabaseInfo dbInfo)
           
private static boolean determineIfDataStoreSupportsFbis()
          Determines if the data store supports Function Based Indexes (FBIs).
(package private) static boolean doesDataStoreSupportFbis()
          Does this version of the Database, and thus SqlGenerator, support Function Based Indexes.
(package private) static boolean doesSqlGeneratorSupportFbis()
          Does this version of the Database, and thus SqlGenerator, support Function Based Indexes.
(package private) static void establishConnection()
           
(package private) static Vector getDbIndexes(String dbTableName)
           
protected  Hashtable getDBSequences()
           
(package private) static Hashtable getDbTableColumns(String tableName)
           
(package private) static String getDroppedTableDoesNotExistErrorCode()
           
(package private) static int getInvalidColumnNameErrorCode()
           
(package private) static DatabaseMetaData getMetaData()
           
(package private) static String getNotNullToNullableErrorCode()
           
(package private) static int getObjectNameMaxLength()
           
static SQLGenerator getSQLGenerator()
          Load and buffer the appropriate SQL generator for the system's configuration.
(package private) static String getSQLTypeAsString(int sqlTypeInd, int length)
          The caller already knows this is a SQL type, and not a custom type.
(package private) static String getStorageText(String conceptualSize)
           
(package private) static boolean installProcedures()
           
(package private) static boolean isABlobType(int sqlTypeInd)
           
(package private) static boolean isASmallBlobType(int sqlTypeInd)
           
(package private) static boolean isAVarchar2TypeLength4000(int sqlTypeInd, int length)
           
(package private) static boolean isSequenceType(int sqlTypeInd)
           
(package private) static boolean isStandardType(String typeName)
           
(package private) static StatementAndResultSet localGetColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
          This is a localized version of the sample OracleDatabaseMetaData.getColumns provided with Oracle 8.0.4.
(package private) static ConnectionProvider newConnectionProvider()
           
(package private) static oracle.jdbc.driver.OracleDriver newDriver()
           
(package private) static void readDbTables(Hashtable dbTablesOrViews, String[] tableOrViewTypes)
           
(package private) static void setRemarksReporting(Connection connection, boolean x)
           
(package private) static boolean testIsAReservedWord(String x)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OLD_COLUMN

static final int OLD_COLUMN
See Also:
Constant Field Values

NEW_COLUMN

static final int NEW_COLUMN
See Also:
Constant Field Values

MOD_COLUMN

static final int MOD_COLUMN
See Also:
Constant Field Values

TINY

private static final String TINY
See Also:
Constant Field Values

SMALL

private static final String SMALL
See Also:
Constant Field Values

MEDIUM

private static final String MEDIUM
See Also:
Constant Field Values

LARGE

private static final String LARGE
See Also:
Constant Field Values

HUGE

private static final String HUGE
See Also:
Constant Field Values

TINYTABLESIZE

static String TINYTABLESIZE

SMALLTABLESIZE

static String SMALLTABLESIZE

MEDIUMTABLESIZE

static String MEDIUMTABLESIZE

LARGETABLESIZE

static String LARGETABLESIZE

HUGETABLESIZE

static String HUGETABLESIZE

BLOBTSNAME

static String BLOBTSNAME

CHUNKSIZE

static String CHUNKSIZE

SERVICE_NAME

static String SERVICE_NAME

DB_DIR

private static String DB_DIR

DB_USER

static String DB_USER

DB_PASSWORD

private static String DB_PASSWORD

DB_SERVICE_URL

private static String DB_SERVICE_URL

DB_SERVICE_DRIVER

private static String DB_SERVICE_DRIVER

JDBC_DRIVER

private static String JDBC_DRIVER

LINE_SEPARATOR

static String LINE_SEPARATOR

NORMALIZE_INDEX_COLUMN_NAMES

static boolean NORMALIZE_INDEX_COLUMN_NAMES

sqlGenerator_

private static SQLGenerator sqlGenerator_

doesSqlGeneratorSupportFbis_

private static boolean doesSqlGeneratorSupportFbis_

doesDataStoreSupportFbis_

private static boolean doesDataStoreSupportFbis_

doesDataStoreSupportFbisIsSet_

private static boolean doesDataStoreSupportFbisIsSet_

connection_

private static Connection connection_
Constructor Detail

Db

Db()
Method Detail

establishConnection

static void establishConnection()
                         throws CompareSchemaException
Throws:
CompareSchemaException

connectToDatabase

static Connection connectToDatabase()
                             throws SQLException
Connect to the database using info in Windchill's properties files. This method exists in this form in order for CompareSchema.java to publicly support the com.ptc.windchill.upgrade.directives.dataload.MigratorRunner class.

Returns:
A connection to the database which can be used, and then must be closed.
Throws:
SQLException - If the JDBC driver is no longer supported by this class.

getSQLTypeAsString

static String getSQLTypeAsString(int sqlTypeInd,
                                 int length)
The caller already knows this is a SQL type, and not a custom type. Convert an "int" representation of the SQL type to a String.

Parameters:
sqlTypeInd - An "int" representing the SQL Type.
length - The VARCHAR2 length of the String representation.
Returns:
The SQL Type as a String.

isSequenceType

static boolean isSequenceType(int sqlTypeInd)

isABlobType

static boolean isABlobType(int sqlTypeInd)

isASmallBlobType

static boolean isASmallBlobType(int sqlTypeInd)

isAVarchar2TypeLength4000

static boolean isAVarchar2TypeLength4000(int sqlTypeInd,
                                         int length)

testIsAReservedWord

static boolean testIsAReservedWord(String x)

createView

static String createView(String class_name,
                         DatabaseInfo dbInfo)
                  throws IOException,
                         WTException
Throws:
IOException
WTException

newDriver

static oracle.jdbc.driver.OracleDriver newDriver()

getInvalidColumnNameErrorCode

static int getInvalidColumnNameErrorCode()

getObjectNameMaxLength

static int getObjectNameMaxLength()

getDroppedTableDoesNotExistErrorCode

static String getDroppedTableDoesNotExistErrorCode()

getNotNullToNullableErrorCode

static String getNotNullToNullableErrorCode()

setRemarksReporting

static void setRemarksReporting(Connection connection,
                                boolean x)

localGetColumns

static StatementAndResultSet localGetColumns(String catalog,
                                             String schemaPattern,
                                             String tableNamePattern,
                                             String columnNamePattern)
                                      throws SQLException
This is a localized version of the sample OracleDatabaseMetaData.getColumns provided with Oracle 8.0.4. It has been modified to work in the hp-ux environment.

Parameters:
catalog - Is always null.
schemaPattern - The DB_USER, all in upper case.
tableNamePattern - The tableName, all in upper case.
columnNamePattern - All columns use '%'.
Returns:
StatementAndResultSet A structure to hold these objects, paired.
Throws:
SQLException - If the executeQuery() failed.

getStorageText

static String getStorageText(String conceptualSize)

isStandardType

static boolean isStandardType(String typeName)

closeResultSet

static void closeResultSet(ResultSet result_set)

closeStatement

static void closeStatement(Statement statement)

getMetaData

static DatabaseMetaData getMetaData()
                             throws SQLException
Throws:
SQLException

createStatement

static Statement createStatement()
                          throws SQLException
Throws:
SQLException

readDbTables

static void readDbTables(Hashtable dbTablesOrViews,
                         String[] tableOrViewTypes)
                  throws CompareSchemaException
Throws:
CompareSchemaException

getDbTableColumns

static Hashtable getDbTableColumns(String tableName)
                            throws CompareSchemaException
Throws:
CompareSchemaException

getDBSequences

protected Hashtable getDBSequences()
                            throws CompareSchemaException
Throws:
CompareSchemaException

getDbIndexes

static Vector getDbIndexes(String dbTableName)
                    throws CompareSchemaException
Throws:
CompareSchemaException

installProcedures

static boolean installProcedures()

newConnectionProvider

static ConnectionProvider newConnectionProvider()

getSQLGenerator

public static SQLGenerator getSQLGenerator()
Load and buffer the appropriate SQL generator for the system's configuration.

Also decides (and remembers) if function based indices are supported based on the type of generator created. This will affect how indices are compared and created.

Returns:
The SQLGenerator.
Throws:
WTRuntimeException - Currently, only the Oracle SQLGenerator is supported.

doesSqlGeneratorSupportFbis

static boolean doesSqlGeneratorSupportFbis()
Does this version of the Database, and thus SqlGenerator, support Function Based Indexes.

Returns:
A true if SqlGenerator supports Function Based Indexes.

doesDataStoreSupportFbis

static boolean doesDataStoreSupportFbis()
Does this version of the Database, and thus SqlGenerator, support Function Based Indexes.

Returns:
A true if SqlGenerator supports Function Based Indexes.

determineIfDataStoreSupportsFbis

private static boolean determineIfDataStoreSupportsFbis()
Determines if the data store supports Function Based Indexes (FBIs).

Returns:
A true if SqlGenerator supports Function Based Indexes.