引用
websphere 下获取jndi,java:comp/env/cas与jdbc/cas的区别:
A.lookup("java:comp/env/cas")与lockup("jdbc/cas")在websphere中都可以使用。两者的差别在于,java:comp/env/cas是websphere建议使用的方式
如果你当前的线程属于websphere的线程,建议使用java:comp/env/cas的方式,否则was的控制台将报出警告。
在web程序中,要实现通过java:comp/env/cas的方式来获得jndi必须在web.xm和ibm-web-bnd.xmi文件里分别添加
web.xml:
<resource-ref id="ResourceRef_1129470735234">
<res-ref-name>cas_ase</res-ref-name>
<res-type>java.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
ibm-web-bnd.xmi:
<resRefBindings xmi:id="ResourceRefBinding_1129470735234" jndiName="jdbc/cas_ase">
<bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1129470735234"/>
</resRefBindings>
以上两段配置的意思是告诉web容器的上下文环境,将应用映射到的jndi资源。然后就可以通过lookup(“java:comp/env/cas/jdbc/cas_ase”)名来获得数据源。
然而,如果你当前执行的线程不在was的容器内,比如说你通过web容器的线程新起了一个子线程,那么该线程将不在容器的上下文内,通过lookup(“java:comp/env/cas/jdbc/cas_ase”)名来获得数据源
将报错,这个时候你只能使用通用的获取jndi资源的方式,就是通过lookup(“jdbc/cas”)来实现。“jdbc/cas”为你在was的资源设定的jndi名.
分享到:
相关推荐
IBM WebSphere MQ是IBM业界领先面向消息的中间件产品,也是MQ系列产品的基础和核心,它使不同的应用程序能够以企业级的性能,在广泛的平台上安全而可靠地通讯。
WebSphere7.0数据源配置与应用程序发布之应用程序发布
websphere配置数据源
sphere中数据源配置说明详细图解
详细的WebSphere数据源配置,一步步解析和分析。
The dictionary defines a portal as a grand or imposing door or entrance; hence, that picture on the cover. In this book, you will learn why the word portal has become a major buzzword in the world of ...
IBM WebSphere MQ 技术白皮书.doc
IBM Information Server FastTrack, IBM WebSphere® Business Glossary, IBM Information Server Business Glossary Anywhere, IBM WebSphere DataStage®, IBM WebSphere Information Analyzer, IBM WebSphere ...
IBM WebSphere应用服务器简介
IBM Websphere MQ 教程之备份与恢复
IBM WebSphere DataStage教程,供datastage学习者使用。
websphere数据源间接映射,有图形文档和连接代码。希望能给你带来帮助。如果有问题可以发mail给我。
IBM WebSphere Portal 解决方案
IBM WebSphere 应用开发实验指导 PDF
IBM websphereMQ 8.0.0.5 lib包; IBM\WebSphere MQ\java\lib下的文件 文件列表: com.ibm.mq.jms.Nojndi.jar com.ibm.mq.pcf.jar com.ibm.mq.allclient.jar com.ibm.mq.postcard.jar com.ibm.mq.axis2.jar ...
IBM WebSphere MQ 8.0 linux 安装包 part3,IBM WebSphere MQ 8.0 linux 安装包 part3
IBM WebSphere MQ入门教程.pdf
IBM webSphere认证的试题,这是我们老师给的
This book offers a customer-focused perspective on building messaging solutions based on JMS and the leading messaging provider, IBM WebSphere Application Server. The author, Kareem Yusuf, uses his ...
IBM WebSphere DataStage Basic Reference Guide