通过JDBC创建Oracle的存储过程

王朝java/jsp·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航