First page Back Continue Last page Graphics
...Continuation of Notes...
Notes:
//================================================
// Private helper methods
//================================================
private void setJDBC() throws EJBException {
try {
// Load driver...
// Get a connection
_conn = DriverManager.getConnection(...);
String strSQL = "insert into customers values( ?, ?, ? )";
_psInsert = _conn.prepareStatement(strSQL);
strSQL = "update customers set lastname = ?, " +
"firstname = ? where _iId = ?";
_psUpdate = _conn.prepareStatement(strSQL);
strSQL = "delete from customers where _iId = ?";
_psDelete = _conn.prepareStatement(strSQL);
strSQL = "select lastname, firstname from customers " +
"where _iId = ?";
_psSelectID = _conn.prepareStatement(strSQL);
}
// Catch SQL exception and convert to EJBException
catch(SQLException se) {
_conn = null; // To indicate failure
throw new EJBException(se);
}
}
private void unsetJDBC() throws EJBException {
try {
_psInsert.close();
_psUpdate.close();
_psDelete.close();
_psSelectID.close();
_conn.close();
}
catch(SQLException se) {
throw new EJBException(se);
}
}
// Continued...