Thursday, February 18, 2010

Tomcat Error Codes Java App Connecting To Mysql Using JDBC On Tomcat 5.5 For Windows ?

Java app connecting to Mysql using JDBC on tomcat 5.5 for windows ? - tomcat error codes

I get the following message and I do not know how to correct it. I have tried different drivers and get the error. I have my bottle of various lib directories. Please help.

Error:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader $ 1.run (Unknown Source)
In java.security.AccessController.doPrivile ... Method)
at java.net.URLClassLoader.findClass (Unknown Source ...)
at java.lang.ClassLoader.loadClass (Unknown Source)
at sun.misc.Launcher $ AppClassLoader.loadCla ... Source)
at java.lang.ClassLoader.loadClass (Unknown Source)
at java.lang.ClassLoader.loadClassInternal (Source ...)
In java.lang.Class.forName0 (Native Method)
in java.lang. Class.forName (Unknown Source)
In TestMysql.main (TestMysql.java: 15)


Code:

javax.sql import .*;
import java.sql .*;


public class TestMysql (

public static void main (String [] args) (
try (
/ * Test loading driver * /
/ / String driver = "com.mysql.jdbc.Driver";

System.out.println ( "=> loading driver:");
Class.forName ( "com.mysql.jdbc.Driver");
System.out.println ( "OK");

/ * Test the connection * /
String url = "jdbc: mysql: / / localhost / Test Data";

System.out.println ( "=> Connection:");
java.sql.DriverManager.getConnection (url, "JAVa "," jsp ");
System.out.println ( "OK");
)
catch (Exception x) (
x.printStackTrace ();
)
)
)

1 comment:

  1. You need MySQL Connector can be in the sun or MySQL, which you like and save to be found. jar, that teaching

    ReplyDelete