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 SummaryFieldsModifier 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 SummaryConstructors
- 
Method SummaryModifier 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- 
prefixPrefix used for JNDI lookups- See Also:
 
- 
DBLookupNameJNDI name used to lookup the DataSource- See Also:
 
- 
tablePrefixDB table prefix. Used to get the appropriate SQL properties
- 
ds
- 
dbConnection
- 
nctx
- 
cofIDprotected int cofID
- 
cofName
- 
cofPriceprotected float cofPrice
 
- 
- 
Constructor Details- 
DBSupportCreate 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- 
initTableInitialize DB table (remove all existing rows). Method is static so that it can be easily called from the Application Client setup method.- Throws:
- Exception
 
- 
getDBConnectionMake sure we have a valid DB connection handy- Throws:
- SQLException
 
- 
closeDBConnectionClose current DB connection, if applicable- Throws:
- SQLException
 
- 
getStmtGeneric method to get a SQL statement for current table. We get the SQL code associated with the DEPLOY__ TS property. - Throws:
- SQLException
 
- 
closeStmtClose 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.
 
-