File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Unable To connect to Database !! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Unable To connect to Database !!" Watch "Unable To connect to Database !!" New topic

Unable To connect to Database !!

Chetan Chauhan

Joined: Oct 03, 2006
Posts: 8
Hello Everybody !!

I use NetBeansIDE4.1 for developing jsp and servlet applications.

It comes with bundled in Tomcat-5.5.7.

I wrote a simple code for database connectivity using MS-ACCESS and

Here is the piece of code:

Connection con;
Statement stat;
String NewLanguage=new String("SPANISH");
String sql=new String("insert into languages values (1,'" + NewLanguage.toLowerCase() + "',1,null,null)");

out.println("<h1>New Language Added...</h1>");

}catch(Exception e){}
It is working fine.

But when i try to deploy the .war file onto a separate machine with TOMCAT-5.5.9 and java libraries and MS-ACCESS database,the code doesnt work. Jsp messages and other effects are running properly but stuff from database is not coming on the page. System-DSN is also proper.

Then i installed TOMCAT 5.5.9 on my machine and called it inside NetBeansIDE4.1. Again the project run fine.

Then what happens when i run the project outside the IDE on the same or different TOMCAT server ?

Can anybody please solve my problem ?
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

the code doesnt work

Can you expand on this? What happens - error message, nothing returned, code kills JVM, ...

Since it works on one machine and not another, I would think it is a configuration problem. Check the driver is installed and the path to it is correct/in your classpath.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
George Stoianov
Ranch Hand

Joined: Jan 15, 2006
Posts: 94
Since you are using odbc make sure you have the same odbc source set up with the same name on the other machine. Otherwise it is not going to work.
I agree. Here's the link:
subject: Unable To connect to Database !!
It's not a secret anymore!