未找到类异常:java.lang.ClassNotFoundException:com.mysql.jdbc.Driver? [英] Class Not Found Exception: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver?

查看:194
本文介绍了未找到类异常: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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆