I connect to a DB2 database and makes the following query. I don't understand why I get the error: "invalid cursor state".
public static void blivPar() { try { Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); stmt.setMaxRows(1000); ResultSet drenge = stmt.executeQuery("SELECT * FROM People WHERE sex='M'"); ResultSet piger = stmt.executeQuery("SELECT * FROM People WHERE sex='F'"); drenge.first(); piger.first(); int i=0; while(drenge.next()) { while(piger.next()) { i++; System.out.print(i); stmt.execute("INSERT INTO Couples Values ('"+drenge.getString(1) + "','" + drenge.getString(2) + "','" + piger.getString(1) + "','" + piger.getString(2) + "')"); } } } catch (Exception ex) { ex.printStackTrace(); } }
Thank you.