结果集未打开。不允许操作 'getString'。确认自动提交已关闭。?

ResultSet not open. Operation 'getString' not permitted. Verify that autocommit is off.?

我正在使用 apache derby,上面的错误是我的代码,实际上我只是没有得到 parents 下的所有 children,它只给我一个级别children,所以请告诉我如何制作树 parent 和 child 但这只给出了一个 child 级别,上面有错误

正在连接

public static Connection getConnection(){

    Connection connection = null;

    try {
        Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();//
        //Get a connection
        connection  = DriverManager.getConnection(dbURL); 
        connection.setAutoCommit(false);
        connection.getAutoCommit();
    } catch (Exception except) {
        System.out.println(except);
    }
    return connection;
}

最后一次读取 rs1 时在第二个循环中出现错误

    Statement stmt;


        stmt = MainUI.getConnection().createStatement();

嵌套结果集是你的问题,我相信。

要打开两个不同的结果集,您必须有两个单独的 Statement 实例,这样每个实例都可以有自己的 ResultSet。否则,运行 同一 Statement 实例上的第二个查询将关闭第一个 ResultSet

有关详细信息,请参阅此答案:

此外,请查看 java.sql.Statement class:

的 Javadocs

By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists.