在web.xml中无需资源引用即可连接到数据源 [英] Connect to Datasource without resource-ref in web.xml

查看:135
本文介绍了在web.xml中无需资源引用即可连接到数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行在tomcat7上的Web应用程序。 tomcat7和全局数据源配置组件是码头门户的一部分。现在,我可以在门户上设置全局数据源,并将其作为ResourceLink添加到(我的应用程序在tomcat上)context.xml中。我想知道是否有一种方法可以通过我的应用程序jdbc代码连接到这些数据源,而无需在我的web.xml中放入资源引用。

I have a web application running on tomcat7. The tomcat7 and a global datasource configuration component are part of a jetty portal. Now, I can setup global datasources on the portal which get added to the context.xml (of my application on tomcat) as a ResourceLink. I want to know if there is a way to connect to these datasources through my application jdbc code without putting in a resource-ref in my web.xml.

(这将帮助我连接到新的数据源名称,而不必重新部署我的WAR文件,而只是添加新的资源引用标记)

(This will help me connect to new datasource name without redeploying my WAR file just to add new resource-ref tags)

推荐答案

是。由于上下文未正确刷新,我在进行这项工作时遇到了问题。
重新部署后,在上下文中正确设置了ResourceLink,并且Webapp能够执行JNDI查找并连接到数据源。

Seems this works as is. I was having problems in making this work because of my context not refreshing properly. After redeploying, the ResourceLink was setup properly in the context and the webapp was able to do a JNDI lookup and connect to the datasource.

这篇关于在web.xml中无需资源引用即可连接到数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆