wood burning stoves 2.0*
The moose likes JDBC and the fly likes jdbc connectivity working fine in eclipse but not on deploying the same on tomcat by making war Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc connectivity working fine in eclipse but not on deploying the same on tomcat by making war" Watch "jdbc connectivity working fine in eclipse but not on deploying the same on tomcat by making war" New topic
Author

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

jukra singh
Greenhorn

Joined: Jul 24, 2009
Posts: 1
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?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30383
    
150

What error does it give you? If it's driver not found, can you confirm the database driver is in your Tomcat classpath?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdbc connectivity working fine in eclipse but not on deploying the same on tomcat by making war