1 Reply Latest reply on Sep 19, 2001 5:16 PM by dez

    no rows returned

    dez

      Hello

      I posted this question in one of the other forums, but no one seems to be answering it so i thought i'd have better luck here.

      Any how,... i'm just wondering if anyone out there has encountered a problem similar to what i got.

      When i code my entity bean I use bean managed persistence. Thus, in my ejbStore() method i'll have something like the following:

      public void ejbStore() throws RemoteException
      {
      ....
      /*
      * Store in-memory entity bean info into db
      */
      String query = "update mytable " +
      "set firstName = ?,lastName = ?, emailAddress = ? " +
      "where userid = ?" ;

      pstmt = conn.prepareStatement(query);

      pstmt.setString(1, this.firstName);
      pstmt.setString(2, this.lastName);
      pstmt.setString(3, this.emailAddress);
      pstmt.setString(4, this.userid);

      int rowCount = pstmt.executeUpdate() ;
      if (rowCount == 0) {
      throw new EJBException("Storing row for " + userid + " failed.");
      }
      ...
      }

      So, the above is pretty straight forward, i'm just going to update the database using the query with the info that i want. Right?

      Well, unfortunately this doesn't seem to work. The problem here is that the rowCount returned will be 0 and thus will enter the if statement and throw the EJBException. Even when the database has the data in it and the query used in toad returns data (i've check it in toad and yes data should be returned) i get 0 for the rowCount.

      The thing is that if i replace the where clause in the query string defenition from
      "where userid = ?"
      to
      "where userid = '" +variableString+"'"
      i get rows returned. Notice that it is only in the where clause that i have to do this. Oh... and yes the userid variable is a string.

      Right now, it seems to work if i do the above substitution. However, i don't really like this approach and was wondering if anyone else out there had any solutions to this problem or have seen it before?

      Thanks a bunch for you help

      Regards

      Desmond

        • 1. Re: no rows returned
          dez

          Hi guys

          I got it figured out now, the problem was that the database used char rather than varchar2 for it's shcema. After changing that things worked great.