jdbc连接mysql报null问题解决

今天换了个maven来管理项目,在运行之前程序的时候,发现jdbc连接一直报null

跟踪调试了一下,发现是:

connection = DriverManager.getConnection(URL, "root", "123456");

报错:

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.)

为什么会乱码呢,先我加上了编码filter:

 
    <filter>
        <filter-name>charsetEncodingfilter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilterfilter-class>
        <init-param>
            <param-name>encodingparam-name>
            <param-value>UTF-8param-value>
        init-param>
        <init-param>
            <param-name>forceEncodingparam-name>
            <param-value>trueparam-value>
        init-param>
    filter>

    <filter-mapping>
        <filter-name>charsetEncodingfilter-name>
        <url-pattern>/*url-pattern>
    filter-mapping>

并没有什么作用= =;

然后我修改各种idea编码,发现都不起作用,最后我想到今天切换maven的时候我更新了一下jar包,于是我将mysql-connector-java从最新的6.0.3版本换回了5.1.38,
maven坐标:

        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
            <version>5.1.38version>
        dependency>

问题解决了。。。为什么高版本优化不好啊

你可能感兴趣的:(学习,遇到的问题)