A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

10黑马币
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.wsy.dao.Dao.<init>(Dao.java:32)
at com.wsy.dao.Dao.executeQuery(Dao.java:45)
at com.wsy.dao.Dao.check(Dao.java:85)
at com.wsy.iframe.BookLoginIFrame$BookLoginAction.actionPerformed(BookLoginIFrame.java:40)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.wsy.dao.Dao.executeQuery(Dao.java:46)
at com.wsy.dao.Dao.check(Dao.java:85)
at com.wsy.iframe.BookLoginIFrame$BookLoginAction.actionPerformed(BookLoginIFrame.java:40)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

最佳答案

查看完整内容

这个文件,你下载一下。解压后把jar文件放在lib目录下,右键build path ——>add to build path 即可,再不采纳就算了。

24 个回复

倒序浏览
本帖最后由 hakey 于 2015-7-4 15:29 编辑

这个文件,你下载一下。解压后把jar文件放在lib目录下,右键build  path ——>add to build path 即可,再不采纳就算了。

mysql-connector-java-commercial-5.1.33-bin.rar

886.71 KB, 下载次数: 192

回复 使用道具 举报
好像你的电脑没有安装Java运行的环境,看下你的环境变量是否正确
回复 使用道具 举报
ZhangHeng 发表于 2015-6-29 12:44
好像你的电脑没有安装Java运行的环境,看下你的环境变量是否正确

已经配置过了,其他的都好使,就这个不好使
回复 使用道具 举报
必须把mysql-connector-java-5.1.7-bin.jar导入到tomcat的lib目录下面!

在java项目中,只需要引入mysql-connector-java-5.1.7-bin.jar就可以运行java项目。

在web项目中,当Class.forName("om.mysql.jdbc.Driver");时myeclipse是不会去查找字符串,不会去查找驱动的。所以只需要把mysql-connector-java-5.1.7-bin.jar拷贝到tomcat下lib目录就可以了。
回复 使用道具 举报
http://blog.csdn.net/huangbiao86/article/details/6428608 看看这个链接
回复 使用道具 举报
wdd 中级黑马 2015-6-29 19:11:22
7#
xwdxiaoda 发表于 2015-6-29 17:04
http://blog.csdn.net/huangbiao86/article/details/6428608 看看这个链接

这个我弄过了,也不好使
回复 使用道具 举报
本帖最后由 qxc1281 于 2015-6-29 19:28 编辑

把mysql-connect.jar放入网站名/WEB-INF/lib目录中,重启服务器,试一试
回复 使用道具 举报
路途 中级黑马 2015-6-29 20:12:33
9#

你的mysql.jar 这个jar包是放到 /WEB-INF/lib  如果是的话,确定下你下载的jar包没有问题,确定下载完全,或者是官方的jar包吗?如果都确定没问题,那么在jar包上右键   Build Path ----> Add to Build Path

从你的异常来看应该不是Web项目吧,那么就应该是jar包没有编译进去。

那些什么放到/WEB-INF/lib这个路径的都是MyEclipse项目,这个会自动编译。
回复 使用道具 举报
方便把你东西给我发一份吗,我看看,这个应该是驱动写错了,或者驱动jar包错误
回复 使用道具 举报
wdd 中级黑马 2015-6-30 08:32:25
11#
朙兲 发表于 2015-6-29 20:24
方便把你东西给我发一份吗,我看看,这个应该是驱动写错了,或者驱动jar包错误 ...

可以么,会不会太麻烦了
回复 使用道具 举报
JAVA都配置完的话  看一下你的引用那
回复 使用道具 举报
wdd 发表于 2015-6-30 08:32
可以么,会不会太麻烦了

可以  给我吧 1305919293@qq.com
回复 使用道具 举报
wdd 中级黑马 2015-7-1 08:51:20
14#

我先解决一下,解决不了在发给你 :lol
回复 使用道具 举报
数据没有添加到数据库
回复 使用道具 举报
必须把mysql-connector-java-5.1.7-bin.jar导入到tomcat的lib目录下面!

在java项目中,只需要引入mysql-connector-java-5.1.7-bin.jar就可以运行java项目。

在web项目中,当Class.forName("om.mysql.jdbc.Driver");时myeclipse是不会去查找字符串,不会去查找驱动的。所以只需要把mysql-connector-java-5.1.7-bin.jar拷贝到tomcat下lib目录就可以了。
:lol
回复 使用道具 举报
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver:应该是没有引入mysql驱动导致的
回复 使用道具 举报
是不是jar包问题
回复 使用道具 举报
我想是没连接数据库没传上数据,类和类之间没连接
回复 使用道具 举报
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
你没有引mysql的jar包
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 加入黑马