error
In the JSP of JavaWeb, the MySQL database reports an error, and the com.Mysql.JDBC.Driver
cannot be found.
The error log is as follows:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1858)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1709)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at utils.DBUtils.getConnection(DBUtils.java:14)
at dao.UserDao.selectAll(UserDao.java:27)
at servlet.UserServlet.doPost(UserServlet.java:28)
at servlet.UserServlet.doGet(UserServlet.java:47)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
reason
Experienced people understand that there is no third-party package added, but it is added in this project, but it is not found.
To view the project structure:
The third-party package is added under external libraries in the following way:
This cannot be taken in Java Web, and the path of jar package cannot be read.
Solution:
Create a lib
folder in the Web/WEB-INF
directory, and then copy the jar package to this folder to successfully use the database.
Similar Posts:
- JavaWeb Error:java.lang.NumberFormatException: null
- java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
- Web Project Error: javax.servlet.ServletException: Circular view path [registerForm]
- [Solved] Cannot call sendError() after the response has been committed
- [Solved] layui url: rendering data error (thymeleaf)
- [Soloved] Fastdfs Error: java.net.SocketTimeoutException: connect timed out
- springcloud Load balancer does not have available server for client:XXXX
- [Solved] Warning: Servlet threw load() exception java.lang.ClassNotFoundException: org.glassfish.jersey.servlet…
- [Solved] springboot thymeleaf property is empty error: el1007e