存储过程
CREATE PROCEDURE [dbo].[Rtest]
@bdate datetime, //参数
@edate datetime,
@district varchar(6)
as
begin
select s.name,count(i.id) as number from scenic s,info i where s.id=i.entid and i.usertypeid =303 and i.classid=1
and (i.pdate between @bdate and @edate) and s.districtid =@district group by s.name
end
hibernate程序
Session session = HibernateSessionFactory.getSession();
Connection con=session.connection(); //一定要有
String procedure = "{call Rtest(?,?,?)}";
CallableStatement cstmt = null;
ResultSet rs = null;
try {
cstmt = con.prepareCall(procedure); //调用存储过程
//hibernate中一般问号都是从0开始的,但是sql里是从1开始的
cstmt.setString(1,"2007-9-1");
cstmt.setString(2,"2007-9-17"); //存储过程里的参数是datetime类型,sql可以自动把String类型转换但是必须是数据库中要的格式 2007/9/7,2007-9-1 都可以
cstmt.setString(3,"230102");
rs = cstmt.executeQuery(); //执行
while(rs.next()){
System.out.println(rs.getInt(2)); //读取
}
}finally {
session.close(); //关闭session
}
分享到:
相关推荐
hibernate调用存储过程 hibernate调用存储过程 hibernate调用存储过程 hibernate调用存储过程 hibernate调用存储过程 hibernate调用存储过程 hibernate调用存储过程
使用hibernate的query调用oracle的存储过程/function,包含例子,源码以及数据库文件
java调用hibernate存储过程详细介绍,各种配置方法,还有与jdbc调用存储过程二者之间的对比。
hibernate本对数据库的操作有些不完美,有必要的时候可以调用存储过程来补足。
hibernate调用存储过程的方法,里面有典型的例题,欢迎大家下载
hibernate3调用存储过程的用法详细介绍。
在hibernate中调用oracle中的存储过程的详细代码。可以借鉴使用,帮助学习。
在hibernate中使用存储过程,调用存储过程
很好的hibernate开发技术,使用hibernate调用存储过程!
hibernate调用存储过程.docx
hibernate调用存储过程知识.pdf
hibernate调用存储过程[参考].pdf
前几天一直在搞spring+hibernate执行存储过程的技术,在网上查了很多资料没有一个是完全的能执行的,代码简单但,几天时间比较辛苦,所以要分多了点。由于包都太大,所以删掉啦!
hibernate环境搭建已经对应存储过程调用
Hibernate --调用存储过程(全)
1、使用hibernate调用不带参数返回值的存储过程方法public Boolean doInHibernate(Session session) t