在websphere上一个J2EE应用中引用多个数据源JNDI的方法
来源:互联网 发布:versions for mac闪退 编辑:程序博客网 时间:2024/06/15 20:57
1.在WEB-INF下新建文件ibm-web-bnd.xmi中建立两个绑定JNDI名
<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.ejs.models.base.bindings.webappbnd:WebAppBindingxmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"xmlns:com.ibm.ejs.models.base.bindings.webappbnd="webappbnd.xmi"xmi:id="WebAppBinding_1216699055547"virtualHostName="default_host">
<webapp href="WEB-INF/web.xml#WebApp_1216699055562"/>
<resRefBindings xmi:id="ResourceRefBinding_1"jndiName="jdbc/ias">
<bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1"/>
</resRefBindings>
<resRefBindings xmi:id="ResourceRefBinding_1216699055547"jndiName="jdbc/host">
<bindingResourceRefhref="WEB-INF/web.xml#ResourceRef_1216699055547"/>
</resRefBindings>
</com.ibm.ejs.models.base.bindings.webappbnd:WebAppBinding>
2.在WEB.xml文件中两个引用指向(id分别跟上面的web.xml#后面的内容相同)
<resource-ref id="ResourceRef_1">
<description></description>
<res-ref-name>ias</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref id="ResourceRef_1216699055547">
<description></description>
<res-ref-name>host</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
3.在代码中可以引用两个JNDI(不同的数据源)
Context ctx = new InitialContext();
Object obj = ctx.lookup("java:comp/env/host");
ds = (DataSource) obj;
conn = ds.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from c_jgbwhere rownum<10");
Contextctx = new InitialContext();
Object obj = ctx.lookup("java:comp/env/ias");
ds = (DataSource) obj;
conn = ds.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery("select * fromTBUSERSUBPOS where rownum<10");
- 在websphere上一个J2EE应用中引用多个数据源JNDI的方法
- 在websphere上一个J2EE应用中引用多个数据源JNDI的方法[转帖]
- 在websphere上一个J2EE应用中引用多个数据源JNDI的方法
- [J2EE] JNDI定义Oracle数据源的方法
- j2ee规范-jndi-在Tomcat中配置数据源
- 由JDBC浅谈JNDI及其在WebSphere中的配置和企业级应用中DB Session在Spring下的管理
- WebLogic配置JNDI数据源以及如何在应用程序中使用配置好的JNDI数据源
- websphere+spring+jndi数据源配置
- websphere 使用JNDI连接数据源的配置文件编写
- 在spring+hibernate中使用tomcat5.5的jndi数据源
- 在spring中使用tomcat提供的JNDI 数据源
- Tomcat7在JNDI中添加定制的JavaBean数据源
- JNDI在tomcat中的应用:配置数据源
- 在Websphere AppServer 5.1中配置数据源
- 在 WebSphere® Studio 中配置数据源
- 在Tomcat中配制JNDI数据源
- 在Tomcat 6 中配置JNDI数据源
- 在jsp中进行JNDI数据源调试
- strust2 标签的使用
- object类实现了哪些方法(一定要记住!!!)
- 数据流定向
- Bash 高级编程指南的阅读
- hibernate多对一关联关系的映射与原理分析
- 在websphere上一个J2EE应用中引用多个数据源JNDI的方法
- 【Linux 驱动】第九章 与硬件通信
- 如何卸载Eclipse中已安装的插件(卸载插件)
- The provider did not return a ProviderManifestToken string
- SQL SERVER 2012 T-SQL 新增特性-TRY_CONVERT
- 如何将二维数组作为函数的参数传递
- Android 仿 Iphone 自定义滚条视图(wheelview)
- 第二次csdn
- struts2国际化