手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>程序设计>Java技术>列表

通过JDBC创建Oracle的存储过程

来源:互联网 作者:west263.com 时间:2008-02-23
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

public void initReport(File XMLFile, File confFile, File logPrc, File reportPrc, Date runDate) throws InstallException
{
Document bossDoc = converHibernateConfig(xmlFile, confFile);;

String strLogPrc = readFile(logPrc);
String strReportPrc = readFile(reportPrc);

HibernateConfig config = new HibernateConfig();
Session session;
try
{
config.configure(bossDoc);
SessionFactory sessionFactory = config.buildSessionFactory();
session = sessionFactory.openSession();
}catch(Exception exp){
throw new InstallException(exp.getMessage());
}

Transaction tran = null;
try
{
tran = session.beginTransaction();

writeLog("创建WriteLog存储过程");
session.connection().createStatement().execute(strLogPrc);
//writeLog("编译存储过程");
//session.connection().createStatement().execute("compile;");
writeLog("创建dialy_report_proc存储过程");
session.connection().createStatement().execute(strReportPrc);
//writeLog("编译存储过程");
//session.connection().createStatement().execute("compile");
tran.commit();
writeLog("报表数据初始化成功");
}catch(HibernateException exp){
try
{
tran.rollback();
}catch(HibernateException exp1){
throw new InstallException(exp1.getMessage());
}
throw new InstallException(exp.getMessage());
}catch(SQLException exp){
try
{
tran.rollback();
}catch(HibernateException exp1){
throw new InstallException(exp1.getMessage());
}
throw new InstallException(exp.getMessage());
}finally{
try
{
session.close();
}catch(HibernateException exp){
throw new InstallException(exp.getMessage());
}
}
}

另外:需要将存储过程的文件保存为Unix格式,否则不能使用。

上一篇: OSCache入门教程
下一篇: 《面向对象程序构造》的中文摘要

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!