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

    • <bdo id='VMTxC'></bdo><ul id='VMTxC'></ul>
  • <tfoot id='VMTxC'></tfoot>
    <legend id='VMTxC'><style id='VMTxC'><dir id='VMTxC'><q id='VMTxC'></q></dir></style></legend>
    <i id='VMTxC'><tr id='VMTxC'><dt id='VMTxC'><q id='VMTxC'><span id='VMTxC'><b id='VMTxC'><form id='VMTxC'><ins id='VMTxC'></ins><ul id='VMTxC'></ul><sub id='VMTxC'></sub></form><legend id='VMTxC'></legend><bdo id='VMTxC'><pre id='VMTxC'><center id='VMTxC'></center></pre></bdo></b><th id='VMTxC'></th></span></q></dt></tr></i><div id='VMTxC'><tfoot id='VMTxC'></tfoot><dl id='VMTxC'><fieldset id='VMTxC'></fieldset></dl></div>
      1. jdbc sql 错误:语句没有返回结果集

        jdbc sql error: statement did not return a result set(jdbc sql 错误:语句没有返回结果集)
          <tfoot id='PoCw6'></tfoot><legend id='PoCw6'><style id='PoCw6'><dir id='PoCw6'><q id='PoCw6'></q></dir></style></legend>

            <bdo id='PoCw6'></bdo><ul id='PoCw6'></ul>

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

                  <i id='PoCw6'><tr id='PoCw6'><dt id='PoCw6'><q id='PoCw6'><span id='PoCw6'><b id='PoCw6'><form id='PoCw6'><ins id='PoCw6'></ins><ul id='PoCw6'></ul><sub id='PoCw6'></sub></form><legend id='PoCw6'></legend><bdo id='PoCw6'><pre id='PoCw6'><center id='PoCw6'></center></pre></bdo></b><th id='PoCw6'></th></span></q></dt></tr></i><div id='PoCw6'><tfoot id='PoCw6'></tfoot><dl id='PoCw6'><fieldset id='PoCw6'></fieldset></dl></div>
                    <tbody id='PoCw6'></tbody>
                  本文介绍了jdbc sql 错误:语句没有返回结果集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有两个存储过程如下:

                  I have two stored procedures as follows:

                  create stored procedure p1
                  as
                      select * from table1 where datediff(day, table1.[date], getdate())
                  
                  create stored procedure p2
                  as
                     declare @t1 table(
                       ref varchar(20)
                     )
                        insert into @t1 select * from table1 where ref = 'some ref'
                        declare @t2 table(
                        fname varchar(20),
                        lname varchar(20),
                        email varchar(1000)
                    )
                    declare @len int = (select count(ref) from @t1)
                    while @len > 0
                    begin
                    declare @value varchar(20)  = (select top 1 ref from @t1)
                    insert into @t2 select * from table2 where ref = @ref
                    delete from @t1
                    where ref = @value
                    set @len = (select count(ref) from @t1)
                    end
                    select * from @t2
                  

                  Java 代码

                   ....
                   String query = "Execute [p2]";
                  
                   try(CallableStatement cstmt = conn.prepareCall(query);
                       ResultSet rs = cstmt.executeQuery()){
                          ... some code
                      }
                  

                  表变量@t1 保存从表 'table1' 中选择的结果

                  The table variable @t1 hold select result from a table 'table1'

                  变量@len 保存@t1 中的行数

                  The variable @len hold the number of rows in @t1

                  使用<代码>@len >0 作为while循环中的条件,我想从另一个表'table2'中选择记录表变量@t2保存来自'table2'的选择记录

                  Using @len > 0 as condition in while loop, I want to select records from another table 'table2' the table variable @t2 hold the select records from 'table2'

                  delete 语句从@t1 中删除值@len 设置为@t1 中的新行数最后一条语句返回@t2中存储的所有记录

                  The delete statement removes value from @t1 @len set to new number of rows in @t1 the last statement return all the records store in @t2

                  第一个过程运行良好,但第二个过程仅适用于 SQL Server.

                  The first procedure works fine, but the second procedure works only in SQL Server.

                  我在我的 Java 应用程序中收到一条错误消息

                  I get this an error message in my java application

                  语句没有返回结果集

                  我希望它返回一个结果集,其中包含我在查询结束.

                  I want this to return a result set with the select statement I have at the end of the query.

                  请问有没有办法解决这个问题?

                  Please is there a way around this?

                  推荐答案

                  你的 [p2] 存储过程需要在开头包含 SET NOCOUNT ON 以抑制n 受影响的行数"计数,因此 JDBC 不会对它应该放入 ResultSet 的内容感到困惑:

                  Your [p2] stored procedure needs to include SET NOCOUNT ON right at the beginning to suppress the "n rows affected" counts so JDBC doesn't get confused as to what it should put into the ResultSet:

                  CREATE PROCEDURE p2
                  AS
                  
                  SET NOCOUNT ON;
                  
                  declare @t1 table(
                      ref varchar(20)
                  )
                  
                  -- ... and so on
                  

                  有关 SET NOCOUNT 的更多信息,请参阅

                  For more information on SET NOCOUNT see

                  SET NOCOUNT (Transact-SQL)

                  有关从存储过程调用返回的确切内容的详细信息,请参阅

                  For more information on precisely what gets returned from a stored procedure call, see

                  如何从使用 JDBC 的存储过程获取一切

                  这篇关于jdbc sql 错误:语句没有返回结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Accessing another user#39;s table within an Oracle Stored Procedure(在 Oracle 存储过程中访问另一个用户的表)
                  Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)(超出最大存储过程、函数、触发器或视图嵌套级别(限制 32))
                  How to View Oracle Stored Procedure using SQLPlus?(如何使用 SQLPlus 查看 Oracle 存储过程?)
                  How to debug stored procedure in VS 2015?(如何在 VS 2015 中调试存储过程?)
                  How to Pass Java List of Objects to Oracle Stored Procedure Using MyBatis?(如何使用 MyBatis 将 Java 对象列表传递给 Oracle 存储过程?)
                  What is dynamic SQL?(什么是动态 SQL?)

                    <tbody id='G7ciX'></tbody>
                • <tfoot id='G7ciX'></tfoot>

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

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

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