Monday, August 2, 2010

Installing MYSQL Connector/J JDBC on Microsoft Windows



Obtaining Connector/J MySQL JDBC Driver



Go to MySQL.com's JDBC section and click the 'Production Release' link for Connector/J:


Click the 'production release' link for Connector/J JDBC Driver


Click the 'production release' link for Connector/J JDBC Driver.

A list of mirrors will be displayed to you. Pick a mirror and download Connector/J driver. Once you are done with downloading the .zip or .gz file, unzip or untar the file to extract the files in a temporary folder.


Installing Connector/J MySQL JDBC Driver


Among the extracted files will be a JAR file with a name like 'mysql-connector-java-3.0.8-stable-bin.jar'. Copy this file to your %JAVA_HOME%/jre/lib/ext folder which on my system happens to be D:\j2sdk1.4.2\jre\lib\ext>.

You should also add the complete path to this JAR file in your CLASSPATH environment variable. In case if you don't know how to do that, go to Start -> Settings -> Control Panel -> System -> Advanced (tab) -> Environment Variables. Double-click 'CLASSPATH' if it is already listed there or click 'New' to create one with the name of 'CLASSPATH'. If you already had a 'CLASSPATH environment variable listed, simply type in (or paste) the complete path including file name in the window that opens up *at the end of* existing CLASSPATH values. If you are creating a new 'CLASSPATH' environment variable then simple enter '.;' and then append the complete path to Connector/J's JAR file.


Note:

The CLASSPATH variable contains a list of semi-colon separated folders and JAR files where JVM will search for Java class files. You should always separate paths with semi-colon (;) so that JVM can understand where one path ends and next one begins. Also keep in mind that in CLASSPATH variable paths, the first path is always '.' (single dot) which means current folder, so that JVM starts the search for Java class files from the current folder.




Window - Environment Variables

Window - Environment Variables



Window - Edit System Variable

Window - Edit System Variable


If you've correctly added the path to Connector/J JDBC driver's JAR file in your CLASSPATH environment variable then you are done with installing MySQL Connector/J JDBC driver.

Tip:

When you make changes to any of your environment variables (like CLASSPATH), close and re-open any open command prompt windows so that they refresh their environment variable value's cache.

0 comments: