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應用沒有啟用之前我們需要對數據庫進行操作,此事spring沒有加載完成,我們依然可以使用jdbc對數據庫進行操作。
實現方法如下
配置一個struts監聽器,
實現ServletContextListener接口
public class HuaweiDBListener implements ServletContextListener {
}
實現接口中方法
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對象直接從ApplicationContet.xml中得到數據源配置。
今天開始寫bolg,慢慢記錄自己技術上的成長~~~