Package com.sun.ts.tests.common.ejb.dba
Class DBSupport
java.lang.Object
com.sun.ts.tests.common.ejb.dba.DBSupport
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CompoundDBSupport,FloatDBSupport,IntegerDBSupport,LongDBSupport,StringDBSupport
Provide basic DB support for TS deployment tests, using The Datasource referenced as 'jdbc/DB1' in the component
environment.
This class is not intended to be used "as is", but rather to be sub-classed by other DB support classes focusing on a
particular DB schema (and in particular on a type of primary key).
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected Stringprotected floatprotected Connectionprotected static final StringJNDI name used to lookup the DataSourceprotected DataSourceprotected TSNamingContextprotected static final StringPrefix used for JNDI lookupsprotected StringDB table prefix. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClose current DB connection, if applicablevoidcloseStmt(PreparedStatement pStmt, ResultSet result) Close the ResultSet and the PreparedStatement in a safely manner and ignoring any SQLException that could be thrown.voidMake sure we have a valid DB connection handyGeneric method to get a SQL statement for current table.static voidinitTable(String tablePrefix, Properties props) Initialize DB table (remove all existing rows).
-
Field Details
-
prefix
Prefix used for JNDI lookups- See Also:
-
DBLookupName
JNDI name used to lookup the DataSource- See Also:
-
tablePrefix
DB table prefix. Used to get the appropriate SQL properties -
ds
-
dbConnection
-
nctx
-
cofID
protected int cofID -
cofName
-
cofPrice
protected float cofPrice
-
-
Constructor Details
-
DBSupport
Create a new DBSupport object. If called from an EJB or a Web component, you must make sure to call TestUtil.init() before creating a new DBSupport object (so that you can safely use TestUtil.getProperty).- Parameters:
tablePrefix- Prefix to use for SQL properties lookups.- Throws:
Exception
-
-
Method Details
-
initTable
Initialize DB table (remove all existing rows). Method is static so that it can be easily called from the Application Client setup method.- Throws:
Exception
-
getDBConnection
Make sure we have a valid DB connection handy- Throws:
SQLException
-
closeDBConnection
Close current DB connection, if applicable- Throws:
SQLException
-
getStmt
Generic method to get a SQL statement for current table. We get the SQL code associated with the DEPLOY__ TS property. - Throws:
SQLException
-
closeStmt
Close the ResultSet and the PreparedStatement in a safely manner and ignoring any SQLException that could be thrown. This method is designed to be called from a finally block to ensure the release of associated resources.
-