1.Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver’. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
解决办法:
将com.mysql.jdbc.Driver 改为 com.mysql.cj.jdbc.Driver即可。
//1.注册驱动
Class.forName("com.mysql.cj.jdbc.Driver");
2.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.
时区错误
解决办法://2.获取数据库连接对象—登录 选择数据库的过程
添加代码 ?serverTimezone=UTC
//2.获取数据库连接对象---登录 选择数据库的过程
conn = DriverManager.getConnection
("jdbc:mysql://localhost:3306/sys?serverTimezone=UTC", "root", "123456");
JDBC常见问题及解决办法
博客主要介绍了JDBC使用中的两个常见问题及解决办法。一是驱动加载问题,将com.mysql.jdbc.Driver改为com.mysql.cj.jdbc.Driver;二是时区错误,在获取数据库连接对象时添加代码?serverTimezone=UTC。
1627

被折叠的 条评论
为什么被折叠?



