java连接到websphere 8.5 配置的Oracle连接池

Sky_580 2015-12-06 04:29:28
哪位大神帮帮忙,急!!!
我在websphere上已经配置好了Oracle连接池,测试没有问题,
我在java中用jndi连上了一个数据源,但另一个怎么也连不上,
不知道哪位大神有什么方法可以解决连接多个数据源的问题
...全文
339 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Sky_580 2015-12-09
  • 打赏
  • 举报
回复
try{ DataSource tDataSource; if(singleDataSource != null) { tDataSource = singleDataSource; }else{ Context tContext = new InitialContext(); if(tContext==null) { throw new Exception("No such Context"); } Object obj; // // if(JUrl.getDBName().startsWith("jdbc/")) // { // obj = tContext.lookup(JUrl.getDBName()); // } // else // { // obj = tContext.lookup("jdbc/"+JUrl.getDBName()); // } // obj = tContext.lookup("java:comp/env/" + JUrl.getDBName()); //// obj = tContext.lookup(JUrl.getDBName()); // tDataSource = (DataSource) obj; tDataSource=(DataSource)tContext.lookup(“jdbc/oracle”);//”jdbc/oracle”为jndi if (tDataSource != null) { con = tDataSource.getConnection(); if (con != null) { System.out.println("Connect succeed from websphere!"); return true; } else { System.out.println("new Connection error ..."); return false; } } else { System.out.println("new DataSource error ..."); return false; } } catch (Throwable e) { System.out.println("look for jndi name error ..."); e.printStackTrace(); return false; } 虽然不知道怎么回事,但把Object转换去掉,两个就都连接成功了。

2,633

社区成员

发帖
与我相关
我的任务
社区描述
WebSphere 是 IBM 的软件平台。它包含了编写、运行和监视全天候的工业强度的随需应变 Web 应用程序和跨平台、跨产品解决方案所需要的整个中间件基础设施,如服务器、服务和工具。
社区管理员
  • WebSphere社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧