[Solved] Tomcat Server Error: java.lang.NullPointerException Csonsole Error ClassNotFoundException: com.mysql.jdbc.Driver

tomcat Server Error:  java.lang.NullPointerException
Type Exception Report

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

java.lang.NullPointerException
	com.gxa.login.dbutils.DBUtils.executeQuery(DBUtils.java:26)
	com.gxa.login.dao.LoginDao.queryInfo(LoginDao.java:16)
	com.gxa.login.service.LoginService.login(LoginService.java:15)
	com.gxa.login.service.LoginServlet.doPost(LoginServlet.java:27)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Note The full stack trace of the root cause is available in the server logs.

 

An error is also reported in the console

Obviously, the driver was not found

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

java.sql.SQLException: No suitable driver found for jdbc: mysql://localhost:3306

Solution: check whether the jar package is correctly placed under web/WEB-INF/lib

Add to the directory to correctly identify and use:

 

Read More: