eclpise连接不上mysql

七月 25, 2017 5:33:54 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:1' did not find a matching property.
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version: Apache Tomcat/9.0.0.M21
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: May 4 2017 22:42:36 UTC
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 9.0.0.0
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 10
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 10.0
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: x86
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: C:\Program Files\Java\jre1.8.0_131
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_131-b11
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: E:\Java 项目.metadata.plugins\org.eclipse.wst.server.core\tmp0
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: F:\java web\apache-tomcat-9.0.0.M21
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=E:\Java 项目.metadata.plugins\org.eclipse.wst.server.core\tmp0
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=F:\java web\apache-tomcat-9.0.0.M21
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=E:\Java 项目.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=F:\java web\apache-tomcat-9.0.0.M21\endorsed
七月 25, 2017 5:33:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=UTF-8
七月 25, 2017 5:33:54 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_131\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_131/bin/client;C:/Program Files/Java/jre1.8.0_131/bin;C:/Program Files/Java/jre1.8.0_131/lib/i386;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\MySQL\MySQL Server 5.7\bin;C:\Program Files\Java\jdk1.8.0_131\bin;C:\Program Files\Java\jdk1.8.0_131\jre\bin;F:\eclipse;;.]
七月 25, 2017 5:33:54 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-nio-8181"]
七月 25, 2017 5:33:55 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
七月 25, 2017 5:33:55 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-nio-8009"]
七月 25, 2017 5:33:55 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
七月 25, 2017 5:33:55 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1874 ms
七月 25, 2017 5:33:55 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service [Catalina]
七月 25, 2017 5:33:55 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/9.0.0.M21
七月 25, 2017 5:33:55 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-nio-8181"]
七月 25, 2017 5:33:55 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-nio-8009"]
七月 25, 2017 5:33:55 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 920 ms
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1109)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:123)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:60)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.jsp.AddBook_jsp._jspService(AddBook_jsp.java:137)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:498)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:796)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1366)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

7个回答

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

你没有相应MySQL的jdbc驱动

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver,找不到Driver,是不是没有mysql的jar包?

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver,找不到Driver,是不是没有mysql的jar包?
mysql驱动下载地址为:http://download.csdn.net/detail/qq_35449428/9910424

首先看异常描述:
最直接的办法是看异常信息中的Cause By: 这后面跟的信息是问题出现的原因

ClassNotFoundException: com.mysql.jdbc.Driver

这个很明显是类找不到异常,这个类是mysql驱动类
你检查eclipse你创建的项目中是否有驱动类(是一个jar包你应该知道),
如果有,看看是不是放错位置了,没有添加到工程中。
如果没有,直接百度下载mysql驱动包添加到你项目就行了。

mysql的驱动包加一下

你需要响应的mysql的驱动包,从官网上下载,然后再将相应的jar导入到类中

看报错的第一行提示,没有找到jdbc驱动,导一下包就OK了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!