You can install the Connector/J package using either the binary or source distribution. The binary distribution provides the easiest method for installation; the source distribution lets you customize your installation further. With either solution, you manually add the Connector/J location to your JavaCLASSPATH.
如何安装呢?
有很多办法。
最简单的办法:
把下载 的文件解压后的 。jar文件 copy到 %JAVA_HOME%\jre\lib\ext 下, %JAVA_HOME就是jdk的安装目录。
这样做之后,每次新建的project 查看 system library 时都会看到 mysql-connector-java-5.1.22-bin.jar这个名字。这正是我们想要的。
还可以在单个项目导入这个jar,选择所选的项目,右键点击my--->build Path--->add external Archiver...选择jdbc驱动,确定。这样做很麻烦,下次建造工程又需要jdbc又要导入。
还可以选择window->preference->java->bulid path-->classpath 增加jar包。这样做也是一劳永逸。
下面是测试的代码:
import java.sql.*;public classMysqlJdbc {public static voidmain(String args[]) {try{
Clas