jdbc连接mysql报错The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one t

mysql8.0在连接jdbc后报错
jdbc连接mysql报错The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one t_第1张图片
源代码:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.mysql.jdbc.Driver;

public class ConnectMysql {

	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		Class.forName("com.mysql.cj.jdbc.Driver");
		String url="jdbc:mysql://localhost:3306/ljj?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL";
		String user="root";
		String password="123";
		Connection conn=DriverManager.getConnection(url,user,password);
		System.out.println(conn);
	}
}

把url改一下

String url="jdbc:mysql://localhost:3306/ljj?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL";

修改url后连接成功
jdbc连接mysql报错The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one t_第2张图片

你可能感兴趣的:(问题)