java用调用sqlServer存储过程 com.microsoft.sqlserver.jdbc.SQLServerException: 该语句没有返回结果集.
USE[gdebp56_hzrl_dev]GO/******Object:StoredProcedure[dbo].[p_basecheck]ScriptDate:07/...
USE [gdebp56_hzrl_dev]
GO
/****** Object: StoredProcedure [dbo].[p_basecheck] Script Date: 07/23/2014 18:52:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[p_basecheck](@dm varchar(30),@mc varchar(200),@bz varchar(200),@RET INT OUT)
as
SET NOCOUNT ON
begin
SET NOCOUNT ON
set @RET=1000
end
上面是sqlServer的存储过程
这里是java HibernateTemplate 用调用 存储过程
public int verifyPm(){
String procdure ="{call p_basecheck(?,?,?,?)}";
CallableStatement cs = null;
try {
cs = getHibernateTemplate().getSessionFactory().openSession().connection().prepareCall(procdure);
} catch (HibernateException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
try {
cs.setString(1, "1" );
cs.setString(2, "2" );
cs.setString(3, "3" );
cs.registerOutParameter(4, Type.INT);
} catch (SQLException e) {
e.printStackTrace();
}
try {
ResultSet rs1 = cs.executeQuery();
if(cs.execute()){
ResultSet rs = cs.executeQuery();
while (rs.next()) {
rs.getInt("RET");
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
} 展开
GO
/****** Object: StoredProcedure [dbo].[p_basecheck] Script Date: 07/23/2014 18:52:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[p_basecheck](@dm varchar(30),@mc varchar(200),@bz varchar(200),@RET INT OUT)
as
SET NOCOUNT ON
begin
SET NOCOUNT ON
set @RET=1000
end
上面是sqlServer的存储过程
这里是java HibernateTemplate 用调用 存储过程
public int verifyPm(){
String procdure ="{call p_basecheck(?,?,?,?)}";
CallableStatement cs = null;
try {
cs = getHibernateTemplate().getSessionFactory().openSession().connection().prepareCall(procdure);
} catch (HibernateException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
try {
cs.setString(1, "1" );
cs.setString(2, "2" );
cs.setString(3, "3" );
cs.registerOutParameter(4, Type.INT);
} catch (SQLException e) {
e.printStackTrace();
}
try {
ResultSet rs1 = cs.executeQuery();
if(cs.execute()){
ResultSet rs = cs.executeQuery();
while (rs.next()) {
rs.getInt("RET");
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询