惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security Archives - TechRepublic
MongoDB | Blog
MongoDB | Blog
量子位
博客园 - 叶小钗
罗磊的独立博客
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News: Ask HN
Hacker News: Ask HN
MyScale Blog
MyScale Blog
GbyAI
GbyAI
Help Net Security
Help Net Security
Y
Y Combinator Blog
Engineering at Meta
Engineering at Meta
Hacker News - Newest:
Hacker News - Newest: "LLM"
Latest news
Latest news
H
Hacker News: Front Page
Blog — PlanetScale
Blog — PlanetScale
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
S
Schneier on Security
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
S
Security @ Cisco Blogs
Recorded Future
Recorded Future
S
Securelist
博客园 - Franky
Application and Cybersecurity Blog
Application and Cybersecurity Blog
A
About on SuperTechFans
N
News and Events Feed by Topic
AI
AI
T
Tenable Blog
N
News | PayPal Newsroom
C
Cybersecurity and Infrastructure Security Agency CISA
V
V2EX - 技术
T
Threat Research - Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
L
LINUX DO - 热门话题
N
Netflix TechBlog - Medium
S
SegmentFault 最新的问题
T
The Blog of Author Tim Ferriss
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google Online Security Blog
Google Online Security Blog
S
Security Affairs
Webroot Blog
Webroot Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - 三生石上(FineUI控件)
C
Comments on: Blog
G
GRAHAM CLULEY

博客园 - daniel-shen

精通EJB-概述 硬件基础知识大全 教程:关于XMLBeans的初步 在客户端进行xslt对xml的xuan渲染 jaxp笔记2007-4-17 6.ZK用户接口标记语言 5.事件的监听和处理 - daniel-shen - 博客园 4.组件的生命周期 3.zk体系结构 "tomcat启动分析"文章读后笔记 jdk5.0 范型说明 java 数组反射例子 HTML小技巧 MessageFormat初步 ResourceBundle 与locale的使用 jni中关于dll的装载问题 java线程-消费者vs生产者 HttpSessionBindingListener实现与应用 用Java Servlets 2.4实现过滤
加和不加java:comp/env/前缀有什么区别?
daniel-shen · 2006-10-24 · via 博客园 - daniel-shen

java:comp/env是标准的J2EE环境查找规则
使用这种方式必须做一次环境名到JNDI名的映射
这种隔离使得在写程序时不必关注真正的JNDI名字
其实说白了跟把JNDI名放到配置文件里是一样的
用法如下,如把java:comp/env/my/datasource映射到
my.ora.dataource

web.xml
<resource-ref>
<res-ref-name>my/datasource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>CONTAINER<res-auth>
</resource-ref>

weblogic.xml
<reference-descriptor>
--<resource-description>
----<res-ref-name>my/datasource</res-ref-name>
----<jndi-name>my.ora.dataource</jndi-name>

而在streamGallay中,ConfDbConnect中也用到了
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
ds = (DataSource) envContext.lookup(ConfSysInfo.dataBase);
对应的tomcat下应用的web.xml中如下:
<resource-ref>
  <description>DB Connection</description>
  <res-ref-name>jdbc/postgresql</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
 </resource-ref>