2 回答

TA貢獻1784條經驗 獲得超8個贊
代碼:
/**
* 獲取數據庫連接方法
*/
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;
}
- 2 回答
- 0 關注
- 3799 瀏覽
添加回答
舉報