程式碼: /** * 獲取資料庫連線方法 */ public Connection getConn() throws Exception { Connection conn = null; try { //connection原始的連線方式可以轉換為OracleConnection Connection con = this.commonDao.getCurrentConnection(); Connection conWas = null; if(this.wasConnection){//使用tomcat請把biz-context-finance.xml中的wasConnection的值設定為false 註釋掉biz-context-core.xml中的id="websphereForOracleConnection"內容 WebSphereNativeJdbcExtractor websphereForOracleConnection = (WebSphereNativeJdbcExtractor)SpringUtils.getSpringBean("websphereForOracleConnection"); conWas = websphereForOracleConnection.getNativeConnection(con); }else{ conWas = con; } conWas.setAutoCommit(false); conn = conWas.getMetaData().getConnection(); } catch (DaoException e) { e.printStackTrace(); } return conn; }
程式碼: /** * 獲取資料庫連線方法 */ public Connection getConn() throws Exception { Connection conn = null; try { //connection原始的連線方式可以轉換為OracleConnection Connection con = this.commonDao.getCurrentConnection(); Connection conWas = null; if(this.wasConnection){//使用tomcat請把biz-context-finance.xml中的wasConnection的值設定為false 註釋掉biz-context-core.xml中的id="websphereForOracleConnection"內容 WebSphereNativeJdbcExtractor websphereForOracleConnection = (WebSphereNativeJdbcExtractor)SpringUtils.getSpringBean("websphereForOracleConnection"); conWas = websphereForOracleConnection.getNativeConnection(con); }else{ conWas = con; } conWas.setAutoCommit(false); conn = conWas.getMetaData().getConnection(); } catch (DaoException e) { e.printStackTrace(); } return conn; }