dcsimg
jdbc:mysql wont work at all
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Brad_Birdwell
Posted On:   Wednesday, July 7, 2004 09:00 PM

I have now 2 different tomcat servers with 2 identical mysql servers. One on a pc and another on my Mandrake Box. I have added the mysql connector jar file to the tomcat server. I continue to get errors because it is not loading the drivers. My java connector code is: Connection conn = null; try { String userName = "UserNameHere" String password = "PasswordHere" String url = "jdbc:mysql://localhost/test" Class.forName ("com.mysql.jdbc.Driver").newInstance (); conn = DriverManager.getConnection (url, userName, password); System.out.println ("Database connection established"); } catch (Exception e) {    More>>

I have now 2 different tomcat servers with 2 identical mysql servers. One on a pc and another on my Mandrake Box. I have added the mysql connector jar file to the tomcat server. I continue to get errors because it is not loading the drivers. My java connector code is:


Connection conn = null;

try
{
String userName = "UserNameHere"
String password = "PasswordHere"
String url = "jdbc:mysql://localhost/test"
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println ("Cannot connect to database server");
System.err.println (e.getMessage());
}
finally
{
if (conn != null)
{
try
{
conn.close ();
System.out.println ("Database connection terminated");
}
catch (Exception e) { /* ignore close errors */ }
}
}



The error stack is
java.lang.NullPointerException
authenticate.doPost(authenticate.java:23)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810



Any ideas...



Thanks

   <<Less
About | Sitemap | Contact