通过JDBC创建Oracle的存储过程

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格式,否则不能使用。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值