MySQL DRIVER: mysql-connector-java-3.1.7.tar.gz
J2SE version: 5.02
Tomcat version: 5.0.30
MySQL: 4.1.10 or 3.23.49 (my version)
First, extract the MySQL driver and there is a mysql-connector-java-3.1.7 package under the mysql-connector-java-3.1.7-bin.jar. Copy it
JAVA installation directory D: ProgramJava
D: Program FilesJavajre1.5.0 _ 02 libext (used to debug Java programs)
And D: Program FilesJavajdk1.5.0 _ 02jrelibext (the Tomcat Program can also be copied to % CATALINA % commonlib)
Another way is to find a directory to store the MySQL driver. Add the path to the path in the system environment variable.
A Java Application example.
// LoadDriver
Import java. SQL. Connection;
Import java. SQL. DriverManager;
Import java. SQL. SQLException;
// Notice, do not import com. mysql. jdbc .*
// Or you will have problems!
Public class LoadDriver {
Public static void main (String [] args ){
Try {
// The newInstance () call is a work around for some
// Broken Java implementations
Class. forName ("com. mysql. jdbc. Driver"). newInstance ();
}
Catch (Exception ex ){
System. out. println (ex );
}
}
}
After debugging, run LoadDriver. class. If no exception is thrown, the driver configuration of the JavaAplication program is successful.
A JSP Example