Java Reference
In-Depth Information
// do nothing
}
/**
* The ejbRemove gets the primary key from the context because it is
possible to do
* a remove right after a find, and ejbLoad may not have been called.
*/
public void ejbRemove() {
Connection con = null;
PreparedStatement ps = null;
try {
con = getConnection();
memberId = (String) context.getPrimaryKey();
ps = con.prepareStatement("DELETE FROM member WHERE member_id=?");
ps.setString(1, memberId);
if (ps.executeUpdate() < 1) {
String error = "Member (" + memberId + ") not found";
System.out.println(error);
throw new NoSuchEntityException(error);
}
} catch (SQLException sqe) {
System.out.println("SQLException: " + sqe);
throw new EJBException (sqe);
} finally {
cleanup(con, ps);
}
}
public String ejbFindByPrimaryKey(String pk) throws
ObjectNotFoundException {
Connection con = null;
PreparedStatement ps = null;
try {
con = getConnection();
ps = con.prepareStatement("SELECT last_name, first_name,
membership_year " +
"FROM member WHERE member_id=?");
ps.setString(1, pk);
ps.executeQuery();
ResultSet rs = ps.getResultSet();
if (rs.next()) {
memberId = pk;
lastName = rs.getString(1);
Search WWH ::




Custom Search