BMP question!

Discussions

EJB programming & troubleshooting: BMP question!

  1. BMP question! (3 messages)

    i am newbie to ejb and simply coding(following the example in "writing bean-manager persistence entity beans") a entity bean in order to connect to database. now i am able to connect to database(oracle7x) and deployed without error message, but i do not know why, when executing client code, it always issue the problem as below(A.):
    it seems that i forget to create the table, but i am sure the table "accounts" is exist. what's up??
    thanks in advice,
    attached with client(B.) and parts of ejb(C.)(for it's too long to post it on board)
    ---------------
    (A.)javax.ejb.CreateException: java.sql.SQLException: Table not found: ACCOUNTS in statement [INSERT INTO ACCOUNTS(ID, OWNERNAME, BALANCE) VALUES ('123-456-7890','J
    ohn Smith',0.0)]
            at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
    RemoteCall.java:245)
            at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
    220)
            at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
            at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub.invokeHom
    e(Unknown Source)
            at org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invokeHome(HomeProxy.
    java:258)
            at org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java
    :182)
            at $Proxy0.create(Unknown Source)
            at EntityBeanTest.AccountClient.main(AccountClient.java:25)
    -----------
    (B.)AccountClient.java
    ...
    ...
    Context ctx = new InitialContext(System.getProperties());
    Object obj = ctx.lookup("Account");//AccountHome
    AccountHome home = (AccountHome) javax.rmi.PortableRemoteObject.narrow(obj,AccountHome.class);
             home.create("123-456-7890","John Smith"); // it seems there has error when goes to here!
    ...
    ...
    --------
    (C.) AccountBean.java
    ...
    ...
      public AccountPK ejbCreate(String accountID, String ownerName) throws CreateException{
          PreparedStatement pstmt = null;
          Connection conn = null;
          try{
              System.out.println("ejbCreate() called...");
              this.accountID = accountID;
              this.ownerName = ownerName;
              this.balance = 0;
              conn = getConnection();
    System.out.println("getConnection successed!...");
              pstmt = conn.prepareStatement("INSERT INTO ACCOUNTS(ID, OWNERNAME, BALANCE) VALUES (?,?,?)");
              pstmt.setString(1,accountID);
    System.out.println("set String accountID...");
              pstmt.setString(2,ownerName);
    System.out.println("set String ownerName...");
              pstmt.setDouble(3,balance);
    System.out.println("set Double balance");
              pstmt.executeUpdate(); // fail at this steps!!!
    System.out.println("execute preparestatment successed! ...");
              return new AccountPK(accountID);
          }catch(Exception e){
              throw new CreateException(e.toString());
          }finally{
              try{if(pstmt!=null){pstmt.close();}}catch(Exception e){}
              try{if(conn!=null){conn.close();}}catch(Exception e){}
          }
      }
    ...
    ...

    Threaded Messages (3)

  2. BMP question![ Go to top ]

    You probably don't have permissions set for your table.

    You have to assign permission to the user that you use to log onto the data base (in your connection pool), to have update access, otherwise you'll get the message you mention.

    Cheers,
    Rick
  3. BMP question![ Go to top ]

    thanks your reply first,
    but i am sure this user who logins to database and executes the prestatement has privilege to insert update delete the accounts table, for, in fact, i use this user to create the table accounts(for accounts this table is only for test as mention in "writing bean-manager persistence entity beans"); is there any other problems may result in such kind of exception?
    thanks in advice,
  4. The same problem[ Go to top ]

    Hy! i have the same problem whit my BMP.
    Can someone tell me the end of the history ?
    Thanks.