db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eduardo S.E. de Castro" <est...@gmail.com>
Subject Two statement in while
Date Mon, 17 Dec 2007 18:45:27 GMT
Hello,

   I have a question about using two PreparedStatements in the same
connection. When I use the following line, I get an exception
java.sql.SQLException: ResultSet not open. Operation 'next' not
permitted. Verify that autocommit is OFF.

        String strQuery = ...
        PreparedStatement pstmt = ...
        ResultSet rs = pstmt.executeQuery();

        while (rs.next()){
            Integer key = rs.getInt("LINE_ID");

            String strQuery2 = ...
            PreparedStatement pstmt2 = ...
            ResultSet rs2 = pstmt2.executeQuery();

            while (rs2.next()){
                ...
            }
            rs2.close();
            pstmt2.close();
        }
        rs.close();
        pstmt.close();

  I tried to set autoCommit to false, but it remains.

Thanks,
Eduardo

Mime
View raw message