02/28/2005
 

com.epicentric.common
Class DBManagerUtils

java.lang.Object
  |
  +--com.epicentric.common.DBManagerUtils

Deprecated. as of version 4.5, to be removed in 8.0 or later. No replacement available at this time. Please see the package com.epicentric.jdbc for possible alternatives.

public class DBManagerUtils
extends Object

Static methods for database interaction, including creating and closing JDBC connections.


Field Summary
static char DEFAULT_SEPARATOR
          Deprecated.  
 
Constructor Summary
DBManagerUtils()
          Deprecated.  
 
Method Summary
static void addBLOBColumn(Connection c, String tableName, String columnName)
          Deprecated. Add a BLOB column to a table (encapsulates portability issues with BLOB type names).
static void addColumn(Connection c, String tableName, com.epicentric.sql.schema.Column column)
          Deprecated. Adds a column to a table (really encapsulates potential portability issues with SQL 'alter table').
static void addColumn(Connection c, String tableName, String columnName, String columnType)
          Deprecated. As of version 3.5. Will be removed in 8.0 or later. Use addColumn(Connection, String, Column) instead.
static PreparedStatement buildInsertStatement(Connection dbConnection, String tableName, Vector colDescriptors)
          Deprecated. Given connection, table name and a vector of DBColumnDescriptors, create an insert statement.
static PreparedStatement buildUpdateStatement(Connection dbConnection, String tableName, Vector updateDescriptors, String whereClause, Vector whereClauseDescriptors)
          Deprecated. Given connection, table name and a vector of DBColumnDescriptors, create an update statement.
static boolean checkForWarning(SQLWarning warn)
          Deprecated. If given SQLWarning is nonull, display the warning message(s), descending through the chained messages, if there are any.
static void closeDBConnection(Connection conn)
          Deprecated. Close the Connection, trapping all exceptions.
static void closeResultSet(ResultSet rs)
          Deprecated. Close the ResultSet, trapping all errors.
static void closeStatement(Statement statement)
          Deprecated. Close the Statement, trapping all exceptions.
static boolean columnExists(Connection c, String tableName, String columnName)
          Deprecated. Check if a table column exists
static void dumpSQLExceptions(SQLException ex)
          Deprecated. Log all SQL exceptions chained within the given SQL exception.
static String getDateFunction(Connection c)
          Deprecated. Return function or other SQL fragment to get current date and time.
static Connection getDBConnection(Properties props)
          Deprecated. Return a database connection, given the key under which to find JDBC setup info in the vignette properties file.
static Connection getDBConnection(String databaseKey)
          Deprecated. Return a database connection, given the key under which to find JDBC setup info in the vignette properties file.
static String getDBStringFromIntArray(int[] intArray)
          Deprecated. Works with getIntArrayFromDBString() to provide a simple encoding and decoding of integer values that can be stored in a single String field.
static String getDBStringFromIntArray(int[] intArray, char separator)
          Deprecated. Integer-to-string encoding, with your choice of separator character.
static int[] getIntArrayFromDBString(String dbString)
          Deprecated. Works with getDBStringFromIntArray() to provide a simple encoding and decoding of integer values that can be stored in a single String field.
static int[] getIntArrayFromDBString(String dbString, char separator)
          Deprecated. Like getIntArrayFromDBString(String), but lets you specify the separator character.
static boolean isIntegrityConstraintViolation(String sqlState)
          Deprecated. Return a boolean indicating whether a given "SQL state" string (taken from SQLException.getSQLState()) indicates an integrity constraint violation such as a uniqueness constraint violation.
static boolean isNoDataFoundException(String sqlState)
          Deprecated. Return a boolean indicating whether a given "SQL state" string (taken from SQLException.getSQLState()) indicates a No Data Found condition.
static boolean isTransactionDeadlock(String sqlState)
          Deprecated. Return a boolean indicating whether a given "SQL state" string (taken from SQLException.getSQLState()) indicates an transaction deadlock resolution.
static String makeUniqueID()
          Deprecated. As of version 4.0. Will be removed in 8.0 or later. Will not be replaced. Use com.epicentric.uid.UniqueIDFactory instead.
static void setupStore(String store)
          Deprecated. Given the name of a database, get its .setup file and create the db using the SQL statements contained within the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SEPARATOR

public static char DEFAULT_SEPARATOR
Deprecated. 
Constructor Detail

DBManagerUtils

public DBManagerUtils()
Deprecated. 
Method Detail

getDBConnection

public static Connection getDBConnection(String databaseKey)
                                  throws SQLException
Deprecated. 
Return a database connection, given the key under which to find JDBC setup info in the vignette properties file.

How it works: a key of "portalbeans.db" would look for a property of the same name in the properties file. If it finds the property, and the property value is "default.db", it looks for the following sub-properties: It tries to create a JDBC connection using that JDBC driver class, database URL, username, and password.

This indirection allows for flexible configuration of JDBC via the properties file: different subsystems of Vignette Portal use different keys. Each key value in the properties file can point to a separate set of JDBC settings, or all key values can point to the same settings. This allows one subsystem's database to be located on a separate machine than another's database.

Note that if the key doesn't find a property in the config file, it uses the missing property name as the value. That means a key of "portalbeans.db" looks for the property "portalbeans.db", and if not found, looks for "portalbeans.db.driver" etc...

See the vignette properties file for more details.
Parameters:
databaseName - e.g. "portalbeans", "persistentscheduler"

getDBConnection

public static Connection getDBConnection(Properties props)
                                  throws SQLException
Deprecated. 
Return a database connection, given the key under which to find JDBC setup info in the vignette properties file.

Parameters:
databaseName - e.g. "portalbeans", "persistentscheduler"

closeDBConnection

public static void closeDBConnection(Connection conn)
Deprecated. 
Close the Connection, trapping all exceptions.

closeResultSet

public static void closeResultSet(ResultSet rs)
Deprecated. 
Close the ResultSet, trapping all errors.

closeStatement

public static void closeStatement(Statement statement)
Deprecated. 
Close the Statement, trapping all exceptions.

checkForWarning

public static boolean checkForWarning(SQLWarning warn)
                               throws SQLException
Deprecated. 
If given SQLWarning is nonull, display the warning message(s), descending through the chained messages, if there are any.

buildInsertStatement

public static PreparedStatement buildInsertStatement(Connection dbConnection,
                                                     String tableName,
                                                     Vector colDescriptors)
                                              throws SQLException
Deprecated. 
Given connection, table name and a vector of DBColumnDescriptors, create an insert statement.
Parameters:
connection - to database
tableName -  
dbDescriptors - is vector of DBColumnDescriptors that will be included in the INSERT.
Returns:
PreparedStatement ready to executeUpdate()

buildUpdateStatement

public static PreparedStatement buildUpdateStatement(Connection dbConnection,
                                                     String tableName,
                                                     Vector updateDescriptors,
                                                     String whereClause,
                                                     Vector whereClauseDescriptors)
                                              throws SQLException
Deprecated. 
Given connection, table name and a vector of DBColumnDescriptors, create an update statement. Building an update statement is more quirky than an insert, because WHERE-clauses can be quite complex. For now, the using routine must prepare the entire where-clause, leaving replacement symbol '?' corresponding to entries in a whereClauseDescriptors vector.
Parameters:
connection - to database
tableName -  
updateDescriptors - is vector of DBColumnDescriptors that will be included in the UPDATE
whereClause - The entire prepared whereClause, including replacement symbols. The replacement symbols will be filled with whereClauseDescriptor values. e.g. "where myColumn1 = ? and myColumn2 < ?"
whereClauseDescriptors - is vector of DBDescriptors that will be included in the WHERE clause. Note this could be null even if there is a whereClause, if the whereClause itself does not require any replacements.
Returns:
PreparedStatement ready to executeUpdate()

getDBStringFromIntArray

public static String getDBStringFromIntArray(int[] intArray)
Deprecated. 
Works with getIntArrayFromDBString() to provide a simple encoding and decoding of integer values that can be stored in a single String field. Uses comma as the separator.
Parameters:
intArray -  
Returns:
String ready to go into database, or null if empty array
See Also:
#getIntArrayFromDBString()

getDBStringFromIntArray

public static String getDBStringFromIntArray(int[] intArray,
                                             char separator)
Deprecated. 
Integer-to-string encoding, with your choice of separator character. See getIntArrayFromDBString(int[]).
Parameters:
intArray -  
separator. -  
Returns:
String is integers separated by the given separator character.
See Also:
#getIntArrayFromDBString()

getIntArrayFromDBString

public static int[] getIntArrayFromDBString(String dbString)
                                     throws NumberFormatException
Deprecated. 
Works with getDBStringFromIntArray() to provide a simple encoding and decoding of integer values that can be stored in a single String field. Uses comma as the separator.
Parameters:
String - from database
Returns:
intArray parsed out, or nulls if string empty
See Also:
#getIntArrayFromDBString()

getIntArrayFromDBString

public static int[] getIntArrayFromDBString(String dbString,
                                            char separator)
                                     throws NumberFormatException
Deprecated. 
Like getIntArrayFromDBString(String), but lets you specify the separator character.

Parameters:
String - from database
Returns:
intArray parsed out, or nulls if string empty
See Also:
DBManagerUtils.getIntArrayFromDBString(String)

dumpSQLExceptions

public static void dumpSQLExceptions(SQLException ex)
Deprecated. 
Log all SQL exceptions chained within the given SQL exception.

setupStore

public static void setupStore(String store)
Deprecated. 
Given the name of a database, get its .setup file and create the db using the SQL statements contained within the file. Most likely they'll be a collection of CREATE TABLE statements.

Format of .setup files: SQL statements separated by blank lines.

The name of the database is the name as used in the implementation.

columnExists

public static boolean columnExists(Connection c,
                                   String tableName,
                                   String columnName)
                            throws SQLException
Deprecated. 
Check if a table column exists

addColumn

public static void addColumn(Connection c,
                             String tableName,
                             com.epicentric.sql.schema.Column column)
                      throws SQLException
Deprecated. 
Adds a column to a table (really encapsulates potential portability issues with SQL 'alter table').

addColumn

public static void addColumn(Connection c,
                             String tableName,
                             String columnName,
                             String columnType)
                      throws SQLException
Deprecated. As of version 3.5. Will be removed in 8.0 or later. Use addColumn(Connection, String, Column) instead.

Adds a column to a table (encapsulates potential portability issues with SQL 'alter table').
See Also:
DBManagerUtils.addColumn(Connection, String, Column)

addBLOBColumn

public static void addBLOBColumn(Connection c,
                                 String tableName,
                                 String columnName)
                          throws SQLException
Deprecated. 
Add a BLOB column to a table (encapsulates portability issues with BLOB type names).

makeUniqueID

public static String makeUniqueID()
Deprecated. As of version 4.0. Will be removed in 8.0 or later. Will not be replaced. Use com.epicentric.uid.UniqueIDFactory instead.

Create a globally unique id. (Not the same as a Microsoft GUID.)
See Also:
UniqueIDFactory

getDateFunction

public static String getDateFunction(Connection c)
                              throws SQLException
Deprecated. 
Return function or other SQL fragment to get current date and time.

isIntegrityConstraintViolation

public static boolean isIntegrityConstraintViolation(String sqlState)
Deprecated. 
Return a boolean indicating whether a given "SQL state" string (taken from SQLException.getSQLState()) indicates an integrity constraint violation such as a uniqueness constraint violation. This method parses the string according to the different SQLState codes used by the different database platforms we support.
Parameters:
sqlState - the string returned by SQLException.getSQLState() when a SQLException occurs.
Returns:
was this an integrity constraint violaiton?

isTransactionDeadlock

public static boolean isTransactionDeadlock(String sqlState)
Deprecated. 
Return a boolean indicating whether a given "SQL state" string (taken from SQLException.getSQLState()) indicates an transaction deadlock resolution. This could occur when two threads are trying to access the same database resource. The usual handling of this case is to retry the transaction. This method is used primary to avoid marking the connection as bad when returning it to the connection pool. This method parses the string according to the different SQLState codes used by the different database platforms we support.
Parameters:
sqlState - the string returned by SQLException.getSQLState() when a SQLException occurs.
Returns:
was this an transaction deadlock?

isNoDataFoundException

public static boolean isNoDataFoundException(String sqlState)
Deprecated. 
Return a boolean indicating whether a given "SQL state" string (taken from SQLException.getSQLState()) indicates a No Data Found condition. This occurs only on the DB2 platform when an UPDATE statement with a WHERE clause does not find any rows. This method parses the string according to the different SQLState codes used by the different database platforms we support.
Parameters:
sqlState - the string returned by SQLException.getSQLState() when a SQLException occurs.
Returns:
was this an no data found exception?

02/28/2005
 

Copyright and Trademark Notices