0 Replies Latest reply on Jun 28, 2002 7:09 AM by George Sun

    custom finder method problem.

    George Sun Newbie

      Hi, all, I am using JBoss 2.4.4 with Sybase 11.5. I am writing a custom finder method for a CMP bena which looks like:

      public Collection ejbFindByDateTime(String time) throws FinderException
      {
      Connection con = null;
      if(debug) System.out.println("position 1");
      try
      {
      con = getConnection();
      if(debug) System.out.println("position 2 con = " + con);

      PreparedStatement statement = con.prepareStatement(
      "SELECT max(ID) from TABLE_TEST where ID like ?" );

      if(debug) System.out.println("position 3.1 statement = " + statement);

      statement.setString(1, time);

      if(debug) System.out.println("position 3.2 statement = " + statement);

      ResultSet resultSet = statement.executeQuery();

      if(debug) System.out.println("positon 4");

      LinkedList queryMatches = new LinkedList();

      if(debug) System.out.println("position 5");

      while(resultSet.next())
      {
      queryMatches.add(resultSet.getString("ID"));
      if(debug) System.out.println("positon 6");
      }

      if(debug) System.out.println("result size = " + queryMatches.size());

      resultSet.close();
      statement.close();
      return queryMatches;
      }
      catch ( SQLException sqle )
      {
      if(debug) System.out.println("position -1");
      throw new EJBException(sqle);
      }
      finally
      {
      try
      {
      if(con != null)
      {
      con.close();
      }

      }
      catch ( SQLException sqle ) {}
      }
      }


      After successfully deploying the bean and run it, the executtion never reaches "positon 4", instead it reached "position -1". That means the PreparedStatement throws some exception. Anyone please help.

      By the way, the same SQL can be executed in command line.

      The running result are as follows:

      ...
      position 1
      position 2 con = org.jboss.pool.jdbc.xa.wrapper.XAClientConnection@753293
      position 3.1 statement = org.jboss.pool.jdbc.PreparedStatementInPool@4478fe
      position 3.2 statement = org.jboss.pool.jdbc.PreparedStatementInPool@4478fe
      position -1
      ...

      Thanks in advance,
      guoqiao