由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - 请高手指教:Tomcat JNDI problem
相关主题
求OpenShift上Spring-quickstart的mysql配置方法A question on application server
[合集] 现在最好的免费和不免费的application server都是什么?国内的java培训
想试试Jboss,下乃个?请问WebSphere多贵?比Weblogic那个贵?
Market share of Tomcat/tcServer, Glassfish, WebSphere, WebLogicDC hot start-up 招 JAVA engineer (sponsor h1b, green-card)
Re: 怎么取到Weblogic server里的所有用户信息?j2ee web 方向的职业规划
weblogic 分布式问题开发前景光明啊
怎么快速掌握J2EE?请教framework
新手上路,请多指教简单的问题,搞不懂了, 帮忙
相关话题的讨论汇总
话题: tomcat话题: jndi话题: datasource话题: mysql话题: defined
进入Java版参与讨论
1 (共1页)
n*******d
发帖数: 4
1
折腾了二个星期了 :(
Tomcat 4.0 on Linux, trying to connect to MySQL
It can't find the data source I defined and throws this error:
javax.servlet.ServletException: Cannot create resource instance
I'm not sure if there's any security setting preventig this?
I can access MySQL using the following jsp code:
Class.forName("org.gjt.mm.mysql.Driver");
Connection dbcon = DriverManager.getConnection(loginUrl,
loginUser, loginPasswd);
Statement statement = dbcon.createSta
l******u
发帖数: 10
2
I didn't see you define the JNDI name for the datasource anywhere is the xml
descriptor. JNDI is a globally accessible infrastructure. The entry you
defined in the web.xml is a resource reference, which should be mapped into
JNDI entry in server specific deployment descriptor (i.e, weblogic.xml).
Anyhow, make sure your have a datasource defined in Tomcat with the correct
JNDI name. You should be able to see the entry on Tomcat Admin Console.
l******u
发帖数: 10
3
If you defined the JNDI name for the datasource on Tomcat platform, you don't
even need to declare a corresponding resource-ref in your web.xml file. Your
jndi lookup code should be able to locate the datasource directly.
m**c
发帖数: 90
4

Tomcat is a little bit tricky to setup DNS. Your server.xml settings are
correct. You don't need any settings in web.xml. The tricky part is how you
get hold of DataSource object via JNDI (Tomcat does thing differently than
other app servers such as WebLogic, WebSphere, etc.). Here is a sample code
to retrieve DataSource object vai JDNI:
InitialContext context = new InitialContext();
Context envContext = (Context)context.lookup("java:comp/env");
DataSource dataSource = (DataSour

【在 n*******d 的大作中提到】
: 折腾了二个星期了 :(
: Tomcat 4.0 on Linux, trying to connect to MySQL
: It can't find the data source I defined and throws this error:
: javax.servlet.ServletException: Cannot create resource instance
: I'm not sure if there's any security setting preventig this?
: I can access MySQL using the following jsp code:
: Class.forName("org.gjt.mm.mysql.Driver");
: Connection dbcon = DriverManager.getConnection(loginUrl,
: loginUser, loginPasswd);
: Statement statement = dbcon.createSta

1 (共1页)
进入Java版参与讨论
相关主题
简单的问题,搞不懂了, 帮忙Re: 怎么取到Weblogic server里的所有用户信息?
j2ee启动时, 启动了tomcat吗?weblogic 分布式问题
Tomcat和什么一起作Application Server?怎么快速掌握J2EE?
Re: [转载] 急!在线等---从Servlet调用AXIS的Web Serv新手上路,请多指教
求OpenShift上Spring-quickstart的mysql配置方法A question on application server
[合集] 现在最好的免费和不免费的application server都是什么?国内的java培训
想试试Jboss,下乃个?请问WebSphere多贵?比Weblogic那个贵?
Market share of Tomcat/tcServer, Glassfish, WebSphere, WebLogicDC hot start-up 招 JAVA engineer (sponsor h1b, green-card)
相关话题的讨论汇总
话题: tomcat话题: jndi话题: datasource话题: mysql话题: defined