tomcat ms access database connection problem

Hi all,

I'm having trouble with the following: I am trying to have a JSP file call a bunch of Java classes sitting inside tomcat which in turn call an ms access database. I specifically need to be able to call Java classes that reside within the classes directory under WEB-INF and I do not want to call the database directly from the JSP. One of my Java classes already has code in it to connect to the database which works outside of Tomcat but when I put it under WEB-INF/classes and call it from my JSP (which imports the class) it stops working. I even pulled the Java code out of the JSP and ran it with all my other java files and it worked but only outside of Tomcat. I tried using JNDI according to this tutorial: http://www.ericsson.com/mobilityworld/sub/open/technologies/open_development_tips/docs/odt_tomcat_db_connection

but it still does not work. Can someone please help me?

p.s. I need to keep the database outside of tomcat (I'm using version 5.5) and I would like to have my java classes do all the connecting to the database and not the jsp.

[1089 byte] By [Mikestera] at [2007-10-3 1:35:50]
# 1
Do you get any error? Can you paste the code that you use to connect using the data source.I guess you would need to create a new ODBC data source too, using the ODBC data sources in your Control Panel giving your Access database to work.
ragh_dra at 2007-7-14 18:33:55 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks for the reply. I already created an ODBC data source but your post made me recheck how I did it and turns out that I registered it under user DSN and not under system DSN and that I had not specified the correct user and password (which I had specified when doing the JNDI). It all works now.

But I have one last question: Application servers like JBoss do db connection pooling but does Tomcat do something like this. I know that EJBs are often used when connection pooling is needed but is there some other way of doing it without the development overhead of EJBs?

Thanks for the help!

Mikestera at 2007-7-14 18:33:55 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Almost all application servers including Tomcat helps you pool your connections. You would need to create a data source and set the configuration parameters. You would get a lot of information if you looked up Tomcat user's guide at apache.org
ragh_dra at 2007-7-14 18:33:55 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Thanks!I'll look at the documentation because I really want to deploy Tomcat in production.
Mikestera at 2007-7-14 18:33:55 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...