Discussions

EJB programming & troubleshooting: EJB1.1 Code issue

  1. EJB1.1 Code issue (1 messages)


    Friends
    According EJB1.1 specification,the callback methods should not throw RemoteException.Now I want to update our EJB1.0 code to EJB1.1.
    How can I handle the below code to make it EJB1.1?
    Thanks
    Selvaraj


    //This is EJB1.0
    public void ejbStore() throws RemoteException {
            if (isModified == true)
            {
                Connection con = dbConnection();
                if (con == null) throw new RemoteException("BillerEJB ejbStore: Couldn't connect to the database.");

             try
                {

                PreparedStatement prepStmt = con.prepareStatement("UPDATE BILLER SET PRODUCTNAME = ?,productid = ? WHERE customerid = ?" );

                prepStmt.setString(1, productName);
                prepStmt.setInt(2, productId);
                prepStmt.executeUpdate();
                prepStmt.close();
                }
                catch (Exception e)
                {
                    System.out.println("Biller EJB ejbStore got an Exception: " + e.getMessage());
                }
                try
                {
                    con.close();
                }
                catch (SQLException sqe)
                {
                    System.out.println("Biller EJB ejbStore closing db connection got an Exception: " + sqe.getMessage());
                }
                isModified = false;
            }
        }

    Threaded Messages (1)

  2. EJB1.1 Code issue[ Go to top ]

    Throw EJBException. EJBEception is unchecked and should not be declared in the throws clause.