How to : JDBC with MySQL

Posted on Fri 07 July 2006 in Life • 1 min read

JDBC (Java Data Base Connectivity) is the basic driver used to connect Java applets or applications to various databases. Here are some of the resources to get started with JDBC :

Windows

http://www.developer.com/java/data/article.php/3417381

*nix

1. Start off with installing the Connector/J package (mysql-connector-java) from here Details are here 2. Next just extract the files in the tar.gz archive using :

tar -xvzf mysql-connector-java.tar.gz 3. Then just copy the jar files to any directory. I moved the jar files to /usr/share/java 4. Then we got to edit the CLASSPATH variable so edit the .bashrc file to contain following options :

</p>
`JAVA_HOME=/usr/java/jdk1.5.0_06/  #root directory where jdk is present  `

export JAVA\_HOME

CLASSPATH=/usr/java/jdk1.5.0\_06/lib/tools.jar:.:/usr/java/jdk1.5.0\_06/lib/dt.jar:\\

/usr/share/java/mysql-connector-java-3.1.13.jar

export CLASSPATH

<p>
</code>

Then try and test the stuff as mentioned here

technorati tags:jdbc, java, mysql, database, dbms