存储过程:
CREATE PROCEDURE .expbackDatabase1
(
@path varchar(128)
)
AS
begin
BACKUP DATABASE DocProc_IMS_nbyz to
end
GO
java语句:
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
public class CSystemCleanDaoImpl extends CDaoBase{
/**
* 备份当前生产库
* @return
* @throws SQLException
* @throws HibernateException
*/
public boolean expDataBaseUp(String path) throws DaoException, HibernateException, SQLException{
Session session = this.getSession();
Transaction t = session.beginTransaction();
Connection con = session.connection();
String procedure = "{call expbackDatabase1(?)}";
CallableStatement cstmt = con.prepareCall(procedure);
cstmt.setString(1, path);
cstmt.executeUpdate();
t.commit();
session.close();
return false;
}
}
调用有返回参数的存储过程:
public String expSeqNo(String opcode,String opdate,int billtype,String seqNo) throws DaoException, HibernateException, SQLException{
String no="";
Session session = this.getSession();
Transaction t = session.beginTransaction();
Connection con = session.connection();
//第四个?是out类型的返回参数,要注册一下这个out返回类型的参数
String pro = "{call sp_GetSeqNo(?,?,?,?)}";
CallableStatement cleancs = con.prepareCall(pro);
cleancs.setString(1, opcode);
cleancs.setString(2, opdate);
cleancs.setInt(3, billtype);
//注册out类型的返回参数
cleancs.registerOutParameter(4, java.sql.Types.INTEGER);
cleancs.executeUpdate();
//接收out类型的返回参数值
no=cleancs.getInt(4)+"";
t.commit();
con.close();
session.close();
return no;
}
相关推荐
hibernate调用存储过程 hibernate调用存储过程 hibernate调用存储过程 hibernate调用存储过程 hibernate调用存储过程 hibernate调用存储过程 hibernate调用存储过程
Struts 1.1、Hibernate 3.0和SQL Server 2005数据库驱动包
使用hibernate的query调用oracle的存储过程/function,包含例子,源码以及数据库文件
hibernate本对数据库的操作有些不完美,有必要的时候可以调用存储过程来补足。
hibernate调用存储过程的方法,里面有典型的例题,欢迎大家下载
在hibernate中调用oracle中的存储过程的详细代码。可以借鉴使用,帮助学习。
java调用hibernate存储过程详细介绍,各种配置方法,还有与jdbc调用存储过程二者之间的对比。
使用Hibernate访问数据库,demo中数据库使用的是sqlserver
使用hibernate对sqlserver 2005进行增删改查
很好的hibernate开发技术,使用hibernate调用存储过程!
一个基于Hibernate 和 SQLServer 数据库的分页示例,所有文件和数据库备份都在,只是速度不怎么快,如果加上自动生成下拉框,速度就更慢了,单表、10008条测试数据,如果哪位大侠改进了查询速度望告之:vni2007@163....
hibernate调用存储过程.docx
使用Hibernate编写通用数据库操作代码
NULL 博文链接:https://ynp.iteye.com/blog/2007053
前几天一直在搞spring+hibernate执行存储过程的技术,在网上查了很多资料没有一个是完全的能执行的,代码简单但,几天时间比较辛苦,所以要分多了点。由于包都太大,所以删掉啦!
hibernate调用存储过程知识.pdf
hibernate3调用存储过程的用法详细介绍。