|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.cementj.util.DatabaseUtility
public class DatabaseUtility
A collection of database oriented utilities.
Copyright: Delta Vortex Technologies, 2002.
Field Summary | |
---|---|
static java.lang.String |
ORACLE_TYPE4_DRIVER
|
static java.lang.String |
SYBASE_JDBC_DRIVER_NAME
|
Constructor Summary | |
---|---|
protected |
DatabaseUtility()
Constructor |
Method Summary | |
---|---|
static void |
close(java.sql.CallableStatement cStmt)
Closes a callable statement logging a warning if a SQLException is encountered. |
static void |
close(java.sql.Connection conn)
Closes a database Connection logging a warning if a SQLException is encountered. |
static void |
close(java.lang.Object dbObj)
Closes a JDBC-related object logging a warning if a SQLException is encountered. |
static void |
close(java.lang.Object dbObj1,
java.lang.Object dbObj2)
Closes JDBC-related objects in the order provided logging a warning if a SQLException is encountered. |
static void |
close(java.lang.Object dbObj1,
java.lang.Object dbObj2,
java.lang.Object dbObj3)
Closes JDBC-related objects in the order provided logging a warning if a SQLException is encountered. |
static void |
close(java.lang.Object dbObj1,
java.lang.Object dbObj2,
java.lang.Object dbObj3,
java.lang.Object dbObj4)
Closes JDBC-related objects in the order provided logging a warning if a SQLException is encountered. |
static void |
close(java.lang.Object dbObj1,
java.lang.Object dbObj2,
java.lang.Object dbObj3,
java.lang.Object dbObj4,
java.lang.Object dbObj5)
Closes JDBC-related objects in the order provided logging a warning if a SQLException is encountered. |
static void |
close(java.sql.PreparedStatement pStmt)
Closes a prepared statement logging a warning if a SQLException is encountered. |
static void |
close(java.sql.ResultSet rs)
Closes a result set logging a warning if a SQLException is encountered. |
static void |
close(java.sql.Statement stmt)
Closes a statement logging a warning if a SQLException is encountered. |
static java.util.Date |
convertTimestampToUtilDate(java.sql.Timestamp ts)
Converts a java.sql.Timestamp to a java.util.Date. |
static java.sql.Timestamp |
convertUtilDateToTimestamp(java.util.Date date)
Converts a java.util.Date to a java.sql.Timestamp. |
static java.sql.Timestamp |
getCurrentTimestamp()
Provides a java.sql.Timestamp set to the current ssytem time. |
static java.sql.Connection |
getJDBCConnection(java.lang.String driverName,
java.lang.String connectString)
Generic utility that returns a database connection using a given driver. |
static java.sql.Connection |
getJDBCConnection(java.lang.String driverName,
java.lang.String connectString,
java.lang.String dbUserID,
java.lang.String password)
Provides a JDBC connection given a DriverManager class name, connect string, userid, and password. |
static java.sql.Connection |
getOracleJDBCConnection(java.lang.String serverName,
int port,
java.lang.String dbInstance,
java.lang.String dbUserID,
java.lang.String password)
This returns an Oracle JDBC Connection based on the connection string, user id and password given. |
static java.sql.ResultSet |
getSerializableResultSet(java.sql.ResultSet inputResultSet)
Converts a ResultSet into a serializable version that can be returned to remote clients. |
static java.sql.Connection |
getSybaseConnection(java.lang.String server,
int port,
java.lang.String userId,
java.lang.String password)
Provides a Sybase database connection using the Sybase-provided driver com.sybase.jdbc2.jdbc.SybDriver. |
static void |
rollback(java.sql.Connection dbConnection)
Rolls back a dataabse transaction logging a warning if a SQLException is encountered. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ORACLE_TYPE4_DRIVER
public static final java.lang.String SYBASE_JDBC_DRIVER_NAME
Constructor Detail |
---|
protected DatabaseUtility()
Method Detail |
---|
public static void close(java.sql.PreparedStatement pStmt)
Use of this version of close eliminates the need for verbose try/catch logic to handle the SQLException.
public static void close(java.sql.Statement stmt)
Use of this version of close eliminates the need for verbose try/catch logic to handle the SQLException.
public static void close(java.sql.CallableStatement cStmt)
Use of this version of close eliminates the need for verbose try/catch logic to handle the SQLException.
public static void close(java.sql.ResultSet rs)
Use of this version of close eliminates the need for verbose try/catch logic to handle the SQLException.
public static void close(java.sql.Connection conn)
Use of this version of close eliminates the need for verbose try/catch logic to handle the SQLException.
public static void close(java.lang.Object dbObj)
Use of this version of close eliminates the need for verbose try/catch logic to handle the SQLException.
This method will generate an IllegalArgumentException if the object passed isn't one of the following classes in java.sql: PreparedStatement, Statement, ResultSet, CallableStatement, or Connection.
public static void close(java.lang.Object dbObj1, java.lang.Object dbObj2)
Use of this version of close eliminates the need for verbose try/catch logic to handle the SQLException.
This method will generate an IllegalArgumentException if the object passed isn't one of the following classes in java.sql: PreparedStatement, Statement, ResultSet, CallableStatement, or Connection.
Objects will be closed in the order listed.
public static void close(java.lang.Object dbObj1, java.lang.Object dbObj2, java.lang.Object dbObj3)
Use of this version of close eliminates the need for verbose try/catch logic to handle the SQLException.
This method will generate an IllegalArgumentException if the object passed isn't one of the following classes in java.sql: PreparedStatement, Statement, ResultSet, CallableStatement, or Connection.
Objects will be closed in the order listed.
public static void close(java.lang.Object dbObj1, java.lang.Object dbObj2, java.lang.Object dbObj3, java.lang.Object dbObj4)
Use of this version of close eliminates the need for verbose try/catch logic to handle the SQLException.
This method will generate an IllegalArgumentException if the object passed isn't one of the following classes in java.sql: PreparedStatement, Statement, ResultSet, CallableStatement, or Connection.
Objects will be closed in the order listed.
public static void close(java.lang.Object dbObj1, java.lang.Object dbObj2, java.lang.Object dbObj3, java.lang.Object dbObj4, java.lang.Object dbObj5)
Use of this version of close eliminates the need for verbose try/catch logic to handle the SQLException.
This method will generate an IllegalArgumentException if the object passed isn't one of the following classes in java.sql: PreparedStatement, Statement, ResultSet, CallableStatement, or Connection.
Objects will be closed in the order listed.
public static java.util.Date convertTimestampToUtilDate(java.sql.Timestamp ts)
Null arguments generate an IllegalArgumentException.
Timestamp
-
public static java.sql.Timestamp convertUtilDateToTimestamp(java.util.Date date)
Null arguments generate an IllegalArgumentException.
Date
-
public static java.sql.Timestamp getCurrentTimestamp()
public static java.sql.Connection getSybaseConnection(java.lang.String server, int port, java.lang.String userId, java.lang.String password) throws java.sql.SQLException, java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException
The Sybase database driver is not provided with CementJ. You need to download and install the Sybase JDBC driver from Sybase at www.sybase.com.
java.sql.SQLException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
public static java.sql.Connection getOracleJDBCConnection(java.lang.String serverName, int port, java.lang.String dbInstance, java.lang.String dbUserID, java.lang.String password) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.sql.SQLException
The Oracle database driver is not provided with CementJ. You need to download and install the Oracle JDBC driver from Oracle Corporation at otn.oracle.com.
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.sql.SQLException
public static java.sql.Connection getJDBCConnection(java.lang.String driverName, java.lang.String connectString, java.lang.String dbUserID, java.lang.String password) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.sql.SQLException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.sql.SQLException
public static java.sql.Connection getJDBCConnection(java.lang.String driverName, java.lang.String connectString) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.sql.SQLException
driverName
- connectString
-
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.sql.SQLException
public static void rollback(java.sql.Connection dbConnection)
Use of this version of rollback eliminates the need for verbose try/catch logic to handle the SQLException.
public static java.sql.ResultSet getSerializableResultSet(java.sql.ResultSet inputResultSet) throws java.sql.SQLException
java.sql.SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |