SQLException: Operation not allowed after ResultSet closed

前端 未结 2 1681
遇见更好的自我
遇见更好的自我 2021-01-24 20:29

I\'m trying to execute the getPendingSalesOrderIDs() method which calls upon method selectInAsending(...).

But this shows a SQLException saying java.sql.SQLException:

相关标签:
2条回答
  • 2021-01-24 20:45

    If db.endSelect() closes your ResultSet, why not remove it (in the selectInAsending() method)?

    You can close your ResultSet in the getPendingSalesOrderIDs() method like so:

    ResultSet r = null;
    
    try {
        ResultSet r = salesOrder.selectInAsending("soNo", "productionStatus = 'pending' and formatID='Zn-Al'", "soNo");
    
    } catch (SQLException e) {
    
    } finally {
        if (r != null) {
            try {
                r.close();
            } catch (SQLException e) {
    
            }
        }
    }
    
    0 讨论(0)
  • 2021-01-24 20:54

    Yes, the problem is with the db.endSelect() call.

    Just return the resultset, and then be sure to call rs.close() once you are finished. This will take care of cleaning things up.

    0 讨论(0)
提交回复
热议问题