如何安装com.mysql.jdbc.Driver [英] How to install com.mysql.jdbc.Driver
问题描述
如何使用 jdk 1.7版为 Fedora17 OS 安装com.mysql.jdbc.Driver 我总是得到一个错误,在我的所有jdbc代码中都找不到类名为:com.mysql.jdbc.Driver的驱动程序.
How do I install com.mysql.jdbc.Driver for Fedora17 O.S using jdk version 1.7 I always get an error of could not find Driver with class name:com.mysql.jdbc.Driver in all my jdbc codes.
推荐答案
假定您已经安装了MySQL,
Assuming that you already have MySQL installed,
-
安装连接器驱动程序. :
yum install libmysql-java
然后确保设置了类路径.
Then make sure that the classpath is set.
export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java.jar
如果要为所有用户设置此设置,则应修改/etc/environment
If you want to set this for all users, you should modify the /etc/environment
instead
如果您使用的是Eclipse,则还可以通过执行以下步骤来做到这一点:
If you are using Eclipse, you can also do this by going through the following steps:
- 选择
Project Properties > Java Build Path
- 选择库标签
- 点击添加外部罐子
- 选择jar文件,在这种情况下为
mysql-connector-java.jar
- Select
Project Properties > Java Build Path
- Select Libries tab
- Click Add External Jars
- Choose the jar file, in this case
mysql-connector-java.jar
这篇关于如何安装com.mysql.jdbc.Driver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!