permaculture playing cards
The moose likes Tomcat and the fly likes JDBC-ODBC problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "JDBC-ODBC problem" Watch "JDBC-ODBC problem" New topic

JDBC-ODBC problem

Jiafan Zhou
Ranch Hand

Joined: Sep 28, 2005
Posts: 193

hi,everyone here.
I developed a Servlet program connecting to the Ms-access database via the JDBC-ODBC bridge bundled with Sun's JDK. It works fine in the NetBean4.1. Following is the Servlet code which gives you a general idea.

Basicaaly, this program connects to the database via JDBC-ODBC bridge and retrieves the data back to the client, works fine in the Netbean. And in the Netbean I do not bother with setting up the CATALINA_HOME, JAVA_HOME etc, just build and run the program, at this stage, everthing seems nice and cool.

Now, when I put this similar program into another computer which has the latest tomcat5.5.x only, the Servlet program doesn't work. Well, the client can access the Servlet program but stuck in the following code and can not get through the database connection.

I thought it was a Tomcat setup problem but having seen the following link in the Tomcat FAQ: Database, my heart was broken.

Do not use JDBC-ODBC bridge

Now what can I do to make the program work and can anybody tell the why the netbean do not have the same problem?
[ December 10, 2005: Message edited by: Jiafan Zhou ]

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
What does "the Servlet program doesn't work" mean? Do you get an exception? If so, post the output of the printStackTrace call so we can have a look at it. If there's no exception, what does the getConnection method return? Can the servlet reach the DB over the network (and is it allowed to do so)?

Speaking more generally, yes, you should not use the JDBC/ODBC bridge in a servlet environment. But if it works on your IDE, it should work in Tomcat, if you're careful not to generate simultaneous accesses.
Anupam Bhatt
Ranch Hand

Joined: Mar 12, 2004
Posts: 81
The only problem which seems to me is that your "another computer" is not able to get through to the database. Try accessing the database with other means [toad etc.] and verify that you can access the database.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
I just noticed that the web server is running on a different machine. Does that machine have ODBC set up in the same way your local machine has, i.e. is 'peopleDB' an accessible ODBC data source?
I agree. Here's the link:
subject: JDBC-ODBC problem
jQuery in Action, 3rd edition