use of jakarta.ejb.RemoveException in project tomee by apache.
the class BasicBmpBean method ejbRemove.
/**
* A container invokes this method before it removes the EJB object
* that is currently associated with the instance. This method
* is invoked when a client invokes a remove operation on the
* enterprise Bean's home interface or the EJB object's remote interface.
* This method transitions the instance from the ready state to the pool
* of available instances.
*/
public void ejbRemove() throws RemoveException, EJBException, RemoteException {
try {
final InitialContext jndiContext = new InitialContext();
final DataSource ds = (DataSource) jndiContext.lookup("java:comp/env/jdbc/basic/entityDatabase");
final Connection con = ds.getConnection();
try {
final PreparedStatement stmt = con.prepareStatement("delete from entity where id = ?");
try {
stmt.setInt(1, primaryKey);
stmt.executeUpdate();
} finally {
stmt.close();
}
} finally {
con.close();
}
} catch (final Exception e) {
e.printStackTrace();
throw new jakarta.ejb.EJBException(e);
}
}
Aggregations