jdbc连接数据库可能遇到的问题
日期: 2020-12-03 分类: 跨站数据 452次阅读
1.Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class is
com.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");
除特别声明,本站所有文章均为原创,如需转载请以超级链接形式注明出处:SmartCat's Blog
标签:jdbc
精华推荐