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 关注
- 3757 浏览
添加回答
举报