编程的蜗牛

颓废,始于首次的懒惰与原谅。

导航

MySQL

1、Exception in thread "main" java.sql.SQLException: 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.

Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/girls?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC", "root", "123456");

?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC

(1)useUnicode=true&characterEncoding=utf8

用来指定编码格式为utf8
(2)serverTimezone=Asia/Shanghai

用来指定区时,springboot 2.0(包括高版本的jdk)如果不配置这个会报时区错误;

我这里指定的是亚洲上海的区时

useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai

注意:xml配置文件配置

 

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="driverClass" value="com.mysql.jdbc.Driver">
    </property> <property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:3306/test1?useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=UTC"></property>
    <property name="user" value="root"></property>
    <property name="password" value="root"></property>
</bean>

 

posted on 2022-03-13 09:38  粼溪  阅读(25)  评论(0)    收藏  举报