5 Replies Latest reply: Nov 30, 2009 10:52 PM by 807580 RSS

    Resultset

    807580
      How to place the cursor of the rs to the initial position after completing the full iteration of the rs using while.next(). I tried using first() method but gettiing sqlexception : ResultSet may only be accessed in a forward direction.
        • 1. Re: Resultset
          DrClap
          You want to read through the whole ResultSet, then position the cursor back at the first row? That's probably not a very good idea (why didn't you just save the data on the first go through?) but if you have to do this, then don't use a FORWARD_ONLY ResultSet. Use one of the scrollable ones.
          • 2. Re: Resultset
            807580
            What you need to do is transfer the data from the ResultSet into a Collection such as an ArrayList and then you can traverse that as much as you like.
            • 3. Re: Resultset
              807580
              I have changed the rs to the scrollable one. When I iterate through the rs object I am getting different exception..

              java.sql.SQLException: No current row in the ResultSet.
                   at net.sourceforge.jtds.jdbc.MSCursorResultSet.getColumn(MSCursorResultSet.java:248)
                   at net.sourceforge.jtds.jdbc.JtdsResultSet.getString(JtdsResultSet.java:930)
                   at net.sourceforge.jtds.jdbc.JtdsResultSet.getString(JtdsResultSet.java:1217)
                   at DB2.getDetails(DB_PDF_Generator.java:222)
                   at DB_PDF_Generator.main(DB_PDF_Generator.java:107)
              • 4. Re: Resultset
                807580
                I have changed the rs to the scrollable one. When I iterate through the rs object I am getting different exception..

                java.sql.SQLException: No current row in the ResultSet.
                     at net.sourceforge.jtds.jdbc.MSCursorResultSet.getColumn(MSCursorResultSet.java:248)
                     at net.sourceforge.jtds.jdbc.JtdsResultSet.getString(JtdsResultSet.java:930)
                     at net.sourceforge.jtds.jdbc.JtdsResultSet.getString(JtdsResultSet.java:1217)
                     at DB2.getDetails(DB_PDF_Generator.java:222)
                     at DB_PDF_Generator.main(DB_PDF_Generator.java:107)
                • 5. Re: Resultset
                  807580
                  Hi Friend,
                  Its done. Thanks for the suggestions....