Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI Data Source

 
Marius Rafailescu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I recently started working on my first web service that has a class for server, one client and several helpful. Tomcat version is 5.5.
Communication between server and client is with SOAP so I used Apache Axis 1.4 and was able to configure it correctly.
And I have some tables in a database which i want to access from the server, but fail to do so under any circumstances.

I modified by adding context.xml file

between <Context ...> and </Context>

Also, I put in web.xml


Connecting to a database is this: (in server.java)


The project was done in NetBeans IDE with Tomcat. The JDBC library folder is in common\lib of tomcat so everything is ok from this point of view.

I noticed something very suspicious: if i put connection code in index.jsp file under web-pages, then it connects successfully. I think it's a problem of context, but I'm not sure, seeing in other tutorials as connecting occurs in other classes (not from index.jsp).

The error message that I receive in the console is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

Thanks in advance.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Marius!

Tomcat 5.5 is obsolete. Apache Axis (Axis1) is obsolete. Putting Java code on JSPs will make Bear growl at you.

Beyond that, if you could get a JNDI lookup to work at one point in your webapp, it should work anywhere in the webapp. I can't see anything obviously wrong with your examples, though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic