java.sql.SQLException: Unknown system variable 'query_cache_size'

后端 未结 10 873
再見小時候
再見小時候 2020-12-06 04:28

I have a app running with JDBC and get data from MySQL, but I can\'t build it because of this error :

java.sql.SQLException: Unknown system variable \'query         


        
相关标签:
10条回答
  • 2020-12-06 04:42

    This exception is related to pom.xml dependency. When I use below dependency in pox.xml:

     <dependency>
          <groupId>mysql</groupId>
          <artifactId>mysql-connector-java</artifactId>
          <version>6.0.5</version>
     </dependency>
    

    It shows exception:Caused by: java.sql.SQLException: Unknown system variable query_cache_size

    But, when I use below dependency:

      <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>8.0.13</version>
      </dependency>
    

    It works.You have to use latest dependency

    0 讨论(0)
  • 2020-12-06 04:44

    I had a similar problem. I resolved it by specifying the version in mysql dependency

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.45</version>
        <scope>runtime</scope>
    </dependency>
    

    Worked like a charm for me.

    0 讨论(0)
  • 2020-12-06 04:45

    query_cache_size was removed in MySQL 8. Check the docs.

    It works with JDBC driver 5.1.44.

    0 讨论(0)
  • 2020-12-06 04:48

    For mysql 8:

    mysql-connector-java-8.0.17.jar (or above) + db.driver=com.mysql.cj.jdbc.Driver instead of com.mysql.jdbc.Driver

    0 讨论(0)
  • 2020-12-06 04:49

    I stuck on this issue, spend full one day and finally i got solution.

    Solution :

    1) Use exact mysql-connector-java jar or dependency as your mysql version.
    2) if your mysql version is 8 or 6+ try to use this "com.mysql.cj.jdbc.Driver" driver class.

    0 讨论(0)
  • 2020-12-06 04:58

    Ok so what I did as metioned above. I just added the mysql-connector-java-5.1.4 to build path and ran the project on my server and connected fine to mysql

    0 讨论(0)
提交回复
热议问题