为了账号安全,请及时绑定邮箱和手机立即绑定

JDBC连接mysql数据库测试的时候可以连接上,但是在Tomcat里面就连接不上了,不知道为啥?

JDBC连接mysql数据库测试的时候可以连接上,但是在Tomcat里面就连接不上了,不知道为啥?

BIG阳 2019-05-22 21:45:11
Serverstartupin11744msjava.lang.ClassNotFoundException:com.mysql.jdbc.Driveratorg.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1291)atorg.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)atjava.lang.Class.forName0(NativeMethod)atjava.lang.Class.forName(UnknownSource)atutil.DBHelper.(DBHelper.java:16)atdao.ItemsDAO.getAllItems(ItemsDAO.java:19)atorg.apache.jsp.index_jsp._jspService(index_jsp.java:146)atorg.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:742)atorg.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)atorg.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)atorg.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:742)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atorg.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)atorg.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)atorg.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)atorg.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)atorg.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)atorg.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)atorg.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)atorg.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)atjava.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(UnknownSource)atorg.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)atjava.lang.Thread.run(UnknownSource)java.sql.SQLException:Nosuitabledriverfoundforjdbc:mysql://localhost:3306/shopping?useUnicode=true&characterEncoding=UTF-8atjava.sql.DriverManager.getConnection(UnknownSource)atjava.sql.DriverManager.getConnection(UnknownSource)atutil.DBHelper.getConnection(DBHelper.java:24)atdao.ItemsDAO.getAllItems(ItemsDAO.java:19)atorg.apache.jsp.index_jsp._jspService(index_jsp.java:146)atorg.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:742)atorg.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)atorg.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)atorg.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:742)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atorg.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)atorg.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)atorg.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)atorg.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)atorg.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)atorg.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)atorg.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)atorg.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)atjava.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(UnknownSource)atorg.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)atjava.lang.Thread.run(UnknownSource)上面是控制台报错信息
查看完整描述

2 回答

?
弑天下

TA贡献1818条经验 获得超8个赞

这个表示,你在tomcat中的项目中缺少jdbc的驱动,如果你的项目是maven项目,那可能是,在打包发布时,没有将maven的jar一起打包。
                            
查看完整回答
反对 回复 2019-05-22
?
qq_笑_17

TA贡献1818条经验 获得超7个赞

java.lang.ClassNotFoundException:com.mysql.jdbc.DriverNosuitabledriverfoundforjdbc:mysql根据以上信息,你需要查看你的tomcat里使用的包是否含有相对应的jar包。
                            
查看完整回答
反对 回复 2019-05-22
  • 2 回答
  • 0 关注
  • 978 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信