未找到类异常:java.lang.ClassNotFoundException:com.mysql.jdbc.Driver? [英] Class Not Found Exception: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver?
问题描述
可能重复:
找不到 com.mysql.jdbc.Driver构建路径中的mysql连接器
Possible Duplicate:
com.mysql.jdbc.Driver not found with mysql connector in buildpath
我正在将MySQL数据库连接到Java程序.当我运行程序时,出现此错误
I'm working on connecting MySQL database to a Java program. When I run my program I am getting this error
未找到类异常:java.lang.ClassNotFoundException:com.mysql.jdbc.Driver
Class Not Found Exception: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
此行
尝试{ Class.forName("com.mysql.jdbc.Driver").newInstance();
try{ Class.forName("com.mysql.jdbc.Driver").newInstance();
那是什么问题?我正在将连接器放在项目的文件中.是正确的还是应该在其他位置?
So, what's the problem? I'm placing the connector in the project's file.. Is the correct or should it be in another location?
OS Windows XP,Eclipse 4.0,mysql连接器5.1.22
OS Windows XP, Eclipse 4.0, mysql connector 5.1.22
推荐答案
JAR文件需要添加到项目类路径.
JAR file need to add to project class path.
First Right click on you Eclipse Project, Project --> Build Path --> Configure Build Path. Under Libraries tab, click Add Jars or "Add External JARs".
这篇关于未找到类异常:java.lang.ClassNotFoundException:com.mysql.jdbc.Driver?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!