Java Reference
In-Depth Information
"membership_year=? WHERE member_id=?");
ps.setString(1, lastName);
ps.setString(2, firstName);
ps.setInt(3, membershipYear);
ps.setString(4, memberId);
if (ps.executeUpdate() < 1) {
System.out.println("Could not locate member with ID: " +
memberId);
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);
}
}
// business methods defined in the remote interface
public String getLastName() { return lastName; }
public String getFirstName() { return firstName; }
public int getMembershipYear() { return membershipYear; }
public void setLastName(String s) { lastName = s; }
public void setFirstName(String s) { firstName = s; }
public void setMembershipYear(int n) { membershipYear = n; }
// utility methods
private Connection getConnection() throws java.sql.SQLException {
try {
javax.sql.DataSource ds = (javax.sql.DataSource)
ctx.lookup("java:comp/env/jdbc/YachtClubDB");
return ds.getConnection();
} catch(NamingException ne) {
System.out.println("UNABLE to get a connection!");
throw new EJBException(ne);
}
}
private void cleanup(Connection con, PreparedStatement ps) {
try {
Search WWH ::




Custom Search