在做一个图书馆里系统的时候需要用到JDBC来连接数据库 导致乱码和时间不同步问题
其主要原因还是jdbcjar包版本比较高导致的下面是解决问题的办法
在数据库出现乱码可以使用这个办法结局
使用JDBC连接MySql时出现: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
{
在连接字符串后面加上?serverTimezone=UTC
其中UTC是统一标准世界时间。
完整的连接字符串示例:jdbc:mysql://localhost:3306/test?serverTimezone=UTC
或者还有另一种选择:jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8,这个是解决中文乱码输入问题,当然也可以和上面的一起结合:jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
}
test是你自己数据库的名称这个不要弄错
扫描二维码关注公众号,回复:
4598936 查看本文章