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格式,否则不能使用。
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18