3 Replies Latest reply: Mar 16, 2011 1:58 AM by 814917 RSS

    problem with resultSet.beforeFirst(); and resultSet.isLast()

    730895
      Hello all!
      I have errors in this line:
      resultSet.beforeFirst();
      my full code is:
      connect = DriverManager.getConnection(connectionString, "demo", "demo");
              statement = connect.createStatement();
              resultSet = statement.executeQuery("SELECT feeling FROM DEMO.feelingsWords");
              
      //get the number of rows
              int Count=0;
         while(resultSet.next())
      {
           Count++;
      }
      resultSet.beforeFirst();
      but my resultSet is ok because it enter to while(resultSet.next())
      the errors are
      Exception in thread "main" java.sql.SQLException: The 'beforeFirst()' method is only allowed on scroll cursors.
              at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
              at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
              at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
              at org.apache.derby.impl.jdbc.EmbedResultSet.checkScrollCursor(Unknown Source)
              at org.apache.derby.impl.jdbc.EmbedResultSet.beforeFirst(Unknown Source)
              at datamining.db.db.getRexEpri(db.java:461)
              at datamining.db.db.main(db.java:33)
      Caused by: java.sql.SQLException: The 'beforeFirst()' method is only allowed on scroll cursors.
              at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
              at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
              ... 7 more
      Java Result: 1
      thanks for help