throw new RemoteException("[Bean] " + e.getClass().getName() + " : " + e.getMessage());
}
}
public Account retreiveAccount(final String ssn) throws RemoteException {
final Account acct = new Account();
try {
final DataSource ds = (DataSource) javax.rmi.PortableRemoteObject.narrow(jndiContext.lookup("java:comp/env/datasource"), DataSource.class);
final Connection con = ds.getConnection();
try {
final PreparedStatement stmt = con.prepareStatement("select * from Account where SSN = ?");
try {
stmt.setString(1, ssn);
final ResultSet rs = stmt.executeQuery();
if (!rs.next()) return null;
acct.setSsn(rs.getString(1));
acct.setFirstName(rs.getString(2));
acct.setLastName(rs.getString(3));
acct.setBalance(rs.getInt(4));
} finally {
stmt.close();
}
} finally {
con.close();