为了账号安全,请及时绑定邮箱和手机立即绑定

springboot如何配置多个jndi数据源

springboot如何配置多个jndi数据源

千巷猫影 2019-03-03 04:00:10
springboot如何配置多个jndi数据源
查看完整描述

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;
}

 


查看完整回答
反对 回复 2019-03-10
  • 2 回答
  • 0 关注
  • 3659 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信