• <tfoot id='5vAD2'></tfoot>

      • <bdo id='5vAD2'></bdo><ul id='5vAD2'></ul>

        <legend id='5vAD2'><style id='5vAD2'><dir id='5vAD2'><q id='5vAD2'></q></dir></style></legend>

        <small id='5vAD2'></small><noframes id='5vAD2'>

        <i id='5vAD2'><tr id='5vAD2'><dt id='5vAD2'><q id='5vAD2'><span id='5vAD2'><b id='5vAD2'><form id='5vAD2'><ins id='5vAD2'></ins><ul id='5vAD2'></ul><sub id='5vAD2'></sub></form><legend id='5vAD2'></legend><bdo id='5vAD2'><pre id='5vAD2'><center id='5vAD2'></center></pre></bdo></b><th id='5vAD2'></th></span></q></dt></tr></i><div id='5vAD2'><tfoot id='5vAD2'></tfoot><dl id='5vAD2'><fieldset id='5vAD2'></fieldset></dl></div>
      1. SQLSTATE 24000 - 游标状态无效

        时间:2023-09-30

        <small id='DUSCi'></small><noframes id='DUSCi'>

        1. <tfoot id='DUSCi'></tfoot>

            <tbody id='DUSCi'></tbody>
            • <bdo id='DUSCi'></bdo><ul id='DUSCi'></ul>
              <i id='DUSCi'><tr id='DUSCi'><dt id='DUSCi'><q id='DUSCi'><span id='DUSCi'><b id='DUSCi'><form id='DUSCi'><ins id='DUSCi'></ins><ul id='DUSCi'></ul><sub id='DUSCi'></sub></form><legend id='DUSCi'></legend><bdo id='DUSCi'><pre id='DUSCi'><center id='DUSCi'></center></pre></bdo></b><th id='DUSCi'></th></span></q></dt></tr></i><div id='DUSCi'><tfoot id='DUSCi'></tfoot><dl id='DUSCi'><fieldset id='DUSCi'></fieldset></dl></div>

                <legend id='DUSCi'><style id='DUSCi'><dir id='DUSCi'><q id='DUSCi'></q></dir></style></legend>

                  本文介绍了SQLSTATE 24000 - 游标状态无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我连接到一个 DB2 数据库并进行以下查询.我不明白为什么会出现错误:无效的游标状态".

                  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();
                              }
                  
                          }
                  

                  谢谢.

                  推荐答案

                  在 JDBC Javadocs 上找到了 Statement 接口的这个:用于执行静态 SQL 语句并返回它产生的结果的对象.

                  Found this on the JDBC Javadocs for the Statement interface: "The object used for executing a static SQL statement and returning the results it produces.

                  默认情况下,每个 Statement 对象只能同时打开一个 ResultSet 对象.因此,如果一个 ResultSet 对象的读取与另一个 ResultSet 对象的读取交错,则每个都必须由不同的 Statement 对象生成. Statement 接口中的所有执行方法都会隐式关闭一个 statment 的当前 ResultSet 对象,如果存在打开的对象."请参阅 声明 javadoc

                  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. " see Statement javadoc

                  所以在我看来,如果您希望同时打开两个结果集,您需要两个不同的语句.或者您需要完成第一个 ResultSet 的处理并关闭它,以便您可以重新使用 Statement 来创建第二个 ResultSet.

                  So it looks to me like you need two different Statements if you want two ResultSets open at the same time. Or you need to finish processing your first ResultSet and close it so you can re-use the Statement to create the second ResultSet.

                  这篇关于SQLSTATE 24000 - 游标状态无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用 jdbc 中的 ResultSet.getBinaryStream() 从所有列 下一篇:如何使用给定的 JNDI 名称连接到 Websphere 数据源

                  相关文章

                  最新文章

                  <i id='Oy2i5'><tr id='Oy2i5'><dt id='Oy2i5'><q id='Oy2i5'><span id='Oy2i5'><b id='Oy2i5'><form id='Oy2i5'><ins id='Oy2i5'></ins><ul id='Oy2i5'></ul><sub id='Oy2i5'></sub></form><legend id='Oy2i5'></legend><bdo id='Oy2i5'><pre id='Oy2i5'><center id='Oy2i5'></center></pre></bdo></b><th id='Oy2i5'></th></span></q></dt></tr></i><div id='Oy2i5'><tfoot id='Oy2i5'></tfoot><dl id='Oy2i5'><fieldset id='Oy2i5'></fieldset></dl></div>
                    <tfoot id='Oy2i5'></tfoot>

                      <bdo id='Oy2i5'></bdo><ul id='Oy2i5'></ul>
                  1. <legend id='Oy2i5'><style id='Oy2i5'><dir id='Oy2i5'><q id='Oy2i5'></q></dir></style></legend>

                      <small id='Oy2i5'></small><noframes id='Oy2i5'>