String dateString = null;
SimpleDateFormat sd = new SimpleDateFormat("yyyy/MM/dd");
dateString = sd.format(pumpTime);
PreparedStatement st = con.prepareStatement("{call dbo.HrMin(?,?)}"); st.setString(1,dateString);
st.setInt(2,7);
ResultSet rs = st.executeQuery(); while(rs.next()) {}
procedure is :
USE [NC26]
GO
/****** Object: StoredProcedure [dbo].[HrMin] Script Date: 03/29/2016 15:40:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[HrMin]
-- Add the parameters for the stored procedure here
@date varchar(10),@tagindex smallint
AS
BEGIN
declare @datenew datetime;
-- To datetime datatype
set @datenew=DATEADD(DD,-1,(SELECT CONVERT(datetime, @date)));
set @datenew=CONVERT(varchar(10), @datenew, 111);
create table #finalresults
(
hr int,
val float
)
-- insert the survey table structures for use
insert into #finalresults (hr, val)
Select distinct hr,(Select top 1 val from hrtableView where [email protected]
and [email protected] and hr=t1.hr) from hrtableView t1 where tagindex [email protected]
and [email protected] group by hr;
insert into #finalresults (hr, val)
Select distinct hr,(Select top 1 val from hrtableView1 where [email protected]
and [email protected] and hr=t1.hr) from hrtableView1 t1 where tagindex [email protected]
and [email protected] group by hr;
SELECT hr,val FROM #finalresults
drop table #finalresults
END
GO
error: The statement did not return a result set.
我已经使用callable语句,但得到相同的错误。 我已经使用了Google的很多技巧,但一次又一次地得到同样的错误。声明在调用存储过程中没有返回结果集
的PreparedStatement ST = con.prepareStatement( “{调用dbo.HrMin(,)?}”); st.setString(1,dateString); (2,7); st.setInt(2,7); boolean rs = st.execute(); System.out.println(“rss”+ rs);然后它打印rss错误 –
把过程中的SET NOCOUNT ON将解决错误 –