[code]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());
}
}
}[/code]
另外:需要将存储过程的文件保存为Unix格式,否则不能使用。