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
设置时区后再进行连接即可解决
该花的钱要花,该吃的饭要吃。