今天用 idea写了个工程。结果最后报错,错误信息如下:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1493)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at com.google.model.ConnDB.getConn(ConnDB.java:16)
at com.google.model.GoodsBeanBO.getGoodsBean(GoodsBeanBO.java:23)
at com.google.servlet.showGoodsClServlet.doGet(showGoodsClServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)
java.lang.NullPointerException
at com.google.model.GoodsBeanBO.getGoodsBean(GoodsBeanBO.java:25)
at com.google.servlet.showGoodsClServlet.doGet(showGoodsClServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)

  从头到尾看了好几遍,没发现错误。郁闷的要死。调试。。。调试。。。调试。。。丫的!

  浪费了几个钟头的时间!竟然脑残的忘记 google 了! 最后 google 一下。结果出现了。  

  原来是tomcat找不到MYSQL JAR包!

  必须把mysql-connector-java-5.1.7-bin.jar导入到tomcat的lib目录下面! FUCK!

  在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 这位朋友的帖子!!

Idea运行web项目时,提示java.lang.ClassNotFoundException: com.mysql.jdbc.Driver解决方法的更多相关文章

  1. java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 解决方法

    1.导入mysql-connector-java-5.1.26-bin.jar包,我试着把maven中自动下载下来的mysql-connector-java-5.1.26.jar包导入,还是没能解决问 ...

  2. java.lang.ClassNotFoundException: com.mysql.jdbc.Driver解决方式

    昨天整理桌面的时候将桌面的一堆文件移动到F盘去了,结果导致原来建的一些项目名称所有出现红色感叹号,打开一看,原来是由于我把hibernate的那些jar包移走了.导致user library里那些ja ...

  3. IntelliJ IDEA web项目进行数据库连接时出现java.lang.ClassNotFoundException: com.mysql.jdbc.Driver错误解决办法

    首先看报错信息: 意思是找不到类:  com.mysql.jdbc.Driver.也就是说tomcat找不到MySQL数据库连接要用的jar包! 出现这种错误的原因是: 项目中没有导入这个jar包, ...

  4. sparkshell运行sql报错: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

    下载msyql的连接driver https://download.csdn.net/download/xz360717118/10662304 把其中一个: mysql-connector-java ...

  5. java.lang.ClassNotFoundException: com.mysql.jdbc.Driver解决办法

    这个问题的原因是没有导入mysql连接库,我从官网上下载后照着网上的教程各种导入无果,最后发现是我导入的文件错了.... 官网上下下来的压缩文件是这个,不过这并不是直接要导入的文件,首先解压文件,然后 ...

  6. java web mysql.jar java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 折腾了一上午,找到了这错误的原因.哎……悲剧! 确认包已经被导入web工程目录. 原来是 ...

  7. java链接MySQL数据库时使用com.mysql.jdbc.Connection的包会出红线问题 java.lang.ClassNotFoundException: com.mysql.jdbc.Driver问题

    package com.swift; //这里导入的包是java.sql.Connection而不是com.mysql.jdbc.Connection import java.sql.Connecti ...

  8. java.lang.ClassNotFoundException: com.mysql.jdbc.Driver问题

    java.lang.ClassNotFoundException: com.mysql.jdbc.Driverat org.apache.catalina.loader.WebappClassLoad ...

  9. java中myeclipse连接mysql问题(java.lang.ClassNotFoundException: com.mysql.jdbc.Driver)

    java中myeclipse连接mysql问题(java.lang.ClassNotFoundException: com.mysql.jdbc.Driver) 1.往项目中添加mysql-conne ...

随机推荐

  1. 解决win10“cmd自动弹出一闪而过”问题的方法

    1.禁用CMD win+Q gpedit 打开组策略 用户配置--管理模板--系统--阻止访问命令提示符--已启用. 2.启用PowerShell PS:需要使用CMD时可用powershell代替: ...

  2. NOIp2018爆零记

    Day-2~Day0 考前抱佛脚,赶紧刷刷各种模板 Day 1 在开考之前打好了拍子模板,然后试题密码就发下来了(这是我前面的神仙打了\(100\)多行\(emacs\)的配置\(QAQ\)). 先按 ...

  3. mysql慢查询,死锁解决方案

    1. 先使用root用户登录到MySQL中 2. 使用show processlist查看其查询速率 +----+------+-----------------+------+---------+- ...

  4. Eureka

    Consul vs. Eureka Eureka is a service discovery tool. The architecture is primarily client/server, w ...

  5. 可以精准解析国内外网站的DNS

    Pure DNS https://puredns.cn/ XsicoDNS https://dns.xsico.cn/ Fun DNS http://www.fundns.cn/ Bai DNS ht ...

  6. A1115. Counting Nodes in a BST

    A Binary Search Tree (BST) is recursively defined as a binary tree which has the following propertie ...

  7. c/c++ 大于等于 大于 时间效率比较

    变成汇编,都是: 大于等于和大于都是电路上的处理,时间上应该差不多.

  8. latex 导入pdf

    pdflatex \includepdf[addtotoc={1,section,1,something would show in catalog,cc},pages=-,offset=0cm 0. ...

  9. Map.putAll方法——追加另一个Map对象到当前Map集合

    转: Map.putAll方法——追加另一个Map对象到当前Map集合(转) 该方法用来追加另一个Map对象到当前Map集合对象,它会把另一个Map集合对象中的所有内容添加到当前Map集合对象. 语法 ...

  10. Spring2

    简介:1.Aop编程.2.AspectJ基于xml文件.3.AspectJ基于注解. 4.JdbcTemplate. 5.配置properties文件 1       AOP 1.1   AOP介绍 ...