新建存储过程
USE [数据库名] GO 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 @RET=1000 select 4 retvalue end
java 代码 方法
verifyPm()
类要继承下 HibernateDaoSupport
public int verifyPm(){ String procdure ="{Call p_basecheck(?,?,?,?)}"; int j=0; CallableStatement cs = null; try { cs = getSession().connection().prepareCall(procdure); cs.setString(1, "1" ); cs.setString(2, "2" ); cs.setString(3, "3" ); cs.setInt(4, 1 ); if(cs.execute()){ ResultSet rs = cs.executeQuery(); while (rs.next()) { j=rs.getInt("retvalue");//返回值 } } } catch (HibernateException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return j; }
hibernateTemplate 调用 sqlServer2008存储过程 范列,布布扣,bubuko.com
时间: 2024-10-05 05:31:59