Java Reference
In-Depth Information
// methods defined in EntityBean interface
public void ejbActivate() { }
public void ejbPassivate() { }
public void setEntityContext(EntityContext c) { this.context = c; }
public void unsetEntityContext() { }
public void ejbLoad() {
Connection con = null;
PreparedStatement ps = null;
memberId = (String)context.getPrimaryKey();
try {
con = getConnection();
ps = con.prepareStatement("Select last_name, first_name,
membership_year " +
"FROM member WHERE member_id=?");
ps.setString(1, memberId);
ps.executeQuery();
ResultSet rs = ps.getResultSet();
if (rs.next()) {
lastName = rs.getString(1);
firstName = rs.getString(2);
membershipYear = rs.getInt(3);
} else {
System.out.println ("Member EJB could not load data");
throw new NoSuchEntityException("Could not locate Member with
ID:" +
memberId);
}
} catch (SQLException sqe) {
System.out.println ("SQLException: " + sqe);
throw new EJBException(sqe);
} finally {
cleanup(con, ps);
}
}
public void ejbStore() {
Connection con = null;
PreparedStatement ps = null;
try {
con = getConnection();
ps = con.prepareStatement("UPDATE member SET last_name=?,
firstName=?, " +
Search WWH ::




Custom Search