jdbc sql error: statement did not return a result set

后端 未结 2 1348
不思量自难忘°
不思量自难忘° 2020-12-11 06:47

I have two stored procedures as follows:

create stored procedure p1
as
    select * from table1 where datediff(day, table1.[date], getdate())

create stored          


        
相关标签:
2条回答
  • 2020-12-11 07:23

    use method "execute" instead of "executeQuery".

    0 讨论(0)
  • 2020-12-11 07:48

    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
    

    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

    How to get everything back from a stored procedure using JDBC

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