Java错误解决方案

问题一:JAVA之java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver
错误描述:在写Java Web项目时,需要使用Tomcat结合Mysql数据库。写好代码后,运行时:

网页端错误提示: Type Exception Report
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
java.lang.NullPointerException
com.zyz.servlet.dao.impl.UserDaoImpl.login(UserDaoImpl.java:17)
com.zyz.servlet.LoginServlet.doGet(LoginServlet.java:26)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
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

idea控制台错误提示:java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver

解决方案:如果在网页端连接数据库,在Tomcat中lib文件夹下,也需要加入jdbc的jar包。因此将jdbc的jar包放在Tomcat中lib文件夹中。

解决方案提出依据:暂时还没有找到为啥要这样做。参考的Blessing_H的思路做的。


问题二:java.sql.SQLException The server time zone
问题描述:暂无

IDEA控制台错误提示:java.sql.SQLException: The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

解决方案: 这是由于MySql时区错误引起的,通过设置MySql时区。如:

之前:url =jdbc:mysql://localhost/student
修改后:url =jdbc:mysql://localhost/student?serverTimezone=GMT%2B8
补充:还有很多其他解决方法...

END

你可能感兴趣的:(Java错误解决方案)