create or replace trigger pm4h_hw_db.t_get_sys_bhstore
after insert on pm4h_ad.sys_bhstore
declare
pragma autonomous_transaction;
tablename varchar2(64);
cursor cr is
select bhtable from pm4h_ad.sys_bhstore where bhmodelid = 'TODBH';
begin
open cr;
fetch cr
into tablename;
while cr%found loop
if fun_is_exists_table(tablename) = 0 then
pm4h_hw_db.create_bh_table(tablename);
end if;
fetch cr
into tablename;
end loop;
close cr;
end pm4h_hw_db.t_get_sys_bhstore;
在web應(yīng)用沒(méi)有啟用之前我們需要對(duì)數(shù)據(jù)庫(kù)進(jìn)行操作,此事spring沒(méi)有加載完成,我們依然可以使用jdbc對(duì)數(shù)據(jù)庫(kù)進(jìn)行操作。
實(shí)現(xiàn)方法如下
配置一個(gè)struts監(jiān)聽(tīng)器,
實(shí)現(xiàn)ServletContextListener接口
public class HuaweiDBListener implements ServletContextListener {
}
實(shí)現(xiàn)接口中方法
public void contextInitialized(ServletContextEvent context) {
String serverPath = context.getServletContext().getRealPath("/");
ApplicationContext appC= new FileSystemXmlApplicationContext(serverPath + "WEB-INF\\spring\\applicationContext.xml");
ComboPooledDataSource c = (ComboPooledDataSource) appC.getBean("dataSource");
System.out.println("DriverClass=="+ c.getDriverClass());
}
使用ComboPooledDataSource對(duì)象直接從ApplicationContet.xml中得到數(shù)據(jù)源配置。
今天開(kāi)始寫(xiě)bolg,慢慢記錄自己技術(shù)上的成長(zhǎng)~~~