• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

jdbc connectivity working fine in eclipse but not on deploying the same on tomcat by making war  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a web project in eclipse with database connection using mysql and for connection I used the following code :

public Connection dbConnect() throws Exception{
System.out.println("Listing all table name in Database!");
// strConnect = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=" & gDatabase_Name & ";Data Source=" & gServer_name
// gADOConnection.Open strConnect

Connection con=null;
String url = "jdbc:mysql://localhost:3306/";
String db = "employee";
String driver1 = "com.mysql.jdbc.Driver";

String user = "root";
String pass = "welcome";
try{


Class.forName("com.mysql.jdbc.Driver").newInstance();
con=DriverManager.getConnection ( url+db,user,pass );


System.out.println("end of testDbconnect");

}catch(Exception e){

e.printStackTrace();

}

return con;

}




}



I is running fine but when I made war of it and deployed on tomcat its not connecting to database.
Can anyone tell me the reason? Why its happening so?
 
author & internet detective
Sheriff
Posts: 38560
654
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What error does it give you? If it's driver not found, can you confirm the database driver is in your Tomcat classpath?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!