• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable To connect to Database !!

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
system-DSN

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)");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:dsn_lang");
stat=con.createStatement();
stat.executeUpdate(sql);
stat.close();
con.commit();

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


stat.close();
con.close();
}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 ?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chetan,

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.
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
George
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic