1.MySQL JDBC驱动包下载地址:http://dev.mysql.com/downloads/connector/j/ 版本:mysql-connector-java-5.1.17.zip 2.下载后
1.MySQL JDBC驱动包下载地址:
版本:mysql-connector-java-5.1.17.zip
2.下载后任意目录解压到/mysql-connector-java-5.1.17/mysql-connector-java-5.1.17-bin.jar;
/mysql-connector-java-5.1.17/目录下还有docs和src文件夹,src文件夹里有lib目录;
3.前提:mysql和eclipse环境都安装好,,参照前面blog关于Ubuntu安装j2ee环境和mysql的文章;
4.打开eclispe,进入菜单windows->prefrences,进入Java->Build Path->user libraries,选择新建,命名为mysql,路径为:/mysql-connector-java-5.1.17/mysql-connector-java-5.1.17-bin.jar;
5.创建java project,命名为mysqlcon,右键其,选择Build Path->Add libraries,从列表中选择user library,在next界面中选择上面部署的mysql安装包即可;
6.开发,mysqlcon工程下新建class,命名为my,包为cn,即cn.my的java文件:
VALUES(?,?)}能正确显示和插入即成功!