Spring使用JDBC错误总结

1. 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 utili

由于时区原因导致错误,因为MySQL的默认时区是美国时区,需要修改成计算机当前所在时区即可。

    <!--配置JDBC数据源-->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/spring?serverTimezone=GMT%2B8"/>
        <property name="username" value="root"/>
        <property name="password" value="root"/>
    </bean>
jdbc:mysql://localhost:3306/spring?serverTimezone=GMT%2B8

设置时区后再进行连接即可解决

posted @ 2020-05-11 09:23  老王同鞋  阅读(273)  评论(0编辑  收藏  举报