Listing 1: Handling Subsystem Exceptions
 
 

try {
    // call helper method to get a connection
    java.sql.Connection conn = this.getConnection();
    java.sql.Statement stmnt = conn.createStatement();
    stmnt.execute("select * from orders");

    // handle ResultSet
    ...
    ...
 
    // close resources
    stmnt.close();
    conn.close();
   }
 }
 catch(SQLException ex) {
    // wrap subsystem exception and throw EJBException
    throw new EJBException(ex);
  }