Idea连接数据库问题-The server time zone value '�й���׼ʱ��' is unrecognized or represents more than


代码:

` public void test01() throws PropertyVetoException, SQLException { ComboPooledDataSource dataSource=new ComboPooledDataSource(); dataSource.setDriverClass("com.mysql.jdbc.Driver"); dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8"); dataSource.setUser("root"); dataSource.setPassword("1997zxcvbnm"); Connection connection=dataSource.getConnection(); System.out.println(connection); connection.close(); }` 常见问题: 1.java.sql.SQLException: No suitable driver 可能是mysql和mysql-connector-java的版本不匹配: 参考:mysql-connector-java与Mysql、Java的对应版本> https://blog.csdn.net/lingeio/article/details/93487770 2.JDBC连接数据库 mysql serverTimezone 时差问题-The server time zone value '?й???????' is unrecognized or represents more than one time zone. 解决方法:在JdbcUrl后面添加?serverTimezone=GMT%2B8