连接不到mysql数据库

来源:3-1 使用流程

hsbzzhz

2019-07-07 14:33:01

错误为:

org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: The server time zone value 'AEST' 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.

代码是直接copy老师的源代码,然后参考了跟我有同样问题的同学,

  1. mysql已经开启,密码账号全都确认过

  2. SSLconnection已经关闭 

  3. Establishing SSL connection without server's identity verification is not recommended.
    http://img.mukewang.com/climg/5d2191f100013ed215020931.jpg
写回答

4回答

好帮手慕柯南

2019-07-07

同学你好!抱歉呢老师看错了,还望见谅。同学的驱动应该加上cj呢,并且在url的后面添加一下时区,参考:

http://img.mukewang.com/climg/5d21d20f0001163914220118.jpg

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~

1

hsbzzhz

提问者

2019-07-07

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd">
    <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/selection_course?useUnicode=true&amp;characterEncoding=utf-8"/>
        <property name="username" value="root"/>
        <property name="password" value="123456"/>
    </bean>
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource"/>
    </bean>
    <!--<context:component-scan base-package="com.imooc.sc"/>-->
</beans>

老师,这边是我的xml文件配置

0

好帮手慕柯南

2019-07-07

同学你好!同学的mysql版本是多少呢?建议同学将驱动中的cj去掉,测试一下呢。

http://img.mukewang.com/climg/5d21b17300017da903240065.jpg

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~

0
hsbzzhz
h 老师,我有个蠢问题,请问如何将cj去掉呢。还有我的sql版本是8.0.12
h019-07-07
共1条回复

hsbzzhz

提问者

2019-07-07

mysql版本和导入依赖的版本也是相同的,检查过了

0

0 学习 · 8263 问题

查看课程