db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francesco Rosa <i...@francescorosa.net>
Subject Error: Invalid cursor state - no current row
Date Sat, 27 Oct 2007 09:52:03 GMT
Hello,
i have the database with two tables Opzioni, Preventivi.

This is my code;

public class DerbySample {
  
   public static void main(String args[]) {
      // esempio collegamento a derby con modifiche
      try {
         
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
         String connectionString = 
"jdbc:derby:/Users/harlock/Documents/soft/EsempiJava_15/dati;create=false";
         Connection con = DriverManager.getConnection(connectionString, 
"", "");
         String sql = "select * from preventivi where prvID = 1";
         ResultSet rsPreventivi = 
con.createStatement(ResultSet.TYPE_FORWARD_ONLY, 
ResultSet.CONCUR_UPDATABLE).executeQuery(sql);
         rsPreventivi.next();
         sql = "select * from opzioni";
         //----
         ResultSet rsOpzioni = 
con.createStatement(ResultSet.TYPE_FORWARD_ONLY, 
ResultSet.CONCUR_READ_ONLY).executeQuery(sql);
         while (rsOpzioni.next()) {
            System.out.println(rsOpzioni.getString("opzUtente"));
         }
         rsOpzioni.close();
         //----
         rsPreventivi.updateString("prvUtente", "fran");
         rsPreventivi.updateRow();
         rsPreventivi.close();
         System.out.println("bye bye");
      } catch (Exception ex) {
         System.out.println(ex.toString());
      }

   }
}

Run my sample program i receive the error: Invalid cursor state - no 
current row.
If comment the line;
         ResultSet rsOpzioni = 
con.createStatement(ResultSet.TYPE_FORWARD_ONLY, 
ResultSet.CONCUR_READ_ONLY).executeQuery(sql);
         while (rsOpzioni.next()) {
            System.out.println(rsOpzioni.getString("opzUtente"));
         }
         rsOpzioni.close();

my program work correctly!!!

Why? I don't understand!!!
thans.

Mime
View raw message