简体   繁体   English

java.sql.SQLException:尽管具有最新的 JDBC,但系统变量“query_cache_size”未知

[英]java.sql.SQLException: Unknown system variable 'query_cache_size' despite having latest JDBC

I've been searching for a solution to this problem for two days now, and I finally decided to ask here as I've completely lost hope.我一直在寻找解决这个问题的方法两天了,我终于决定在这里问,因为我完全失去了希望。 I've been trying to connect to a MySQL database with my Jakarta server.我一直在尝试使用我的 Jakarta 服务器连接到 MySQL 数据库。 I've followed a few tutorials to get MySQL working with the JDBC driver.我遵循了一些教程来让 MySQL 与 JDBC 驱动程序一起工作。 Here's the code:这是代码:

public static void fetchFromDB(String query) {
    try {
        Class.forName( "com.mysql.cj.jdbc.Driver" );
    } catch ( ClassNotFoundException e ) {
        e.printStackTrace();
    }
    try {
        con = DriverManager.getConnection( url, user, password );
        Statement statement = con.createStatement();
        ResultSet result = statement.executeQuery( query );
        System.out.println(result);
    } catch ( SQLException e ) {
        e.printStackTrace();
    } finally {
        if ( con != null )
            try {
                con.close();
            } catch ( SQLException ignore ) {
                ignore.printStackTrace();
            }
    }
}

Now, I have JDBC 8.0.21 installed and the MySQL database is in 8.0.13-4.现在,我安装了 JDBC 8.0.21,MySQL 数据库在 8.0.13-4 中。 Despite these versions, I keep getting this error: java.sql.SQLException: Unknown system variable 'query_cache_size'尽管有这些版本,我还是不断收到这个错误: java.sql.SQLException: Unknown system variable 'query_cache_size'

I honestly don't know where the problem is coming from.老实说,我不知道问题出在哪里。 Apparently this happens when the JDBC and MySQL base versions don't go together, but... I have the latest version!显然,当 JDBC 和 MySQL 基础版本不兼容时会发生这种情况,但是......我有最新版本!

Thanks in advance for your help.在此先感谢您的帮助。

The query_cache_size parameter was present in MySQL 5.x, but according to the manual it was removed in MySQL 8.0.3. query_cache_size参数存在于 MySQL 5.x 中,但根据手册,它在 MySQL 8.0.3 中被删除。

I have JDBC 8.0.21 installed and the MySQL database is in 8.0.13-4我安装了 JDBC 8.0.21,MySQL 数据库在 8.0.13-4

(I presume you mean MySQL Connector/J 8.0.21). (我想你的意思是 MySQL Connector/J 8.0.21)。

I honestly don't know where the problem is coming from.老实说,我不知道问题出在哪里。

The error will be coming from the database, but it is simply saying that the parameter is no longer recognized.错误将来自数据库,但它只是说参数不再被识别。

It won't be caused by the MySQL Connector/J driver.它不会由 MySQL Connector/J 驱动程序引起。

It is most likely caused your application (eg executing a SET GLOBAL query_cache_size=... or similar) or a stray option in the JDBC url that your application is using when connecting to the database.这很可能是由于您的应用程序(例如执行SET GLOBAL query_cache_size=...或类似的)或您的应用程序在连接到数据库时使用的 JDBC url 中的一个杂散选项造成的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.sql.SQLException: 未知的系统变量 'query_cache_size' - java.sql.SQLException: Unknown system variable 'query_cache_size' 亚马逊 rds mysql 8 上的未知系统变量“query_cache_size” - Unknown system variable ‘query_cache_size’ on amazon rds mysql 8 java.sql.SQLException:未知的系统变量“ OPTION” - java.sql.SQLException: Unknown system variable 'OPTION' java.sql.SQLException: 未知的系统变量 'tx_isolation' - java.sql.SQLException: Unknown system variable 'tx_isolation' java.sql.SQLException:未知的系统变量'transaction_isolation' - java.sql.SQLException: Unknown system variable 'transaction_isolation' java.sql.SQLException:找不到-JDBC - java.sql.SQLException: not found - JDBC java.sql.SQLException:sun.jdbc.odbc.JdbcOdbc.createSQLException 的一般错误(未知来源) - java.sql.SQLException: General error at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source) java.sql.SQLException:[DataDirect] [SQLServer JDBC驱动程序]未处理的令牌类型:未知的令牌:0x50 - java.sql.SQLException: [DataDirect][SQLServer JDBC Driver]Unhandled token type: Unknown token: 0x50 java JDBC:引起:java.sql.SQLException:数字溢出 - java JDBC : Caused by: java.sql.SQLException: Numeric Overflow 使用JDBC的redshift查询的“ java.sql.SQLException:[Amazon](500310)无效的操作:输入结束时语法错误” - “java.sql.SQLException: [Amazon](500310) Invalid operation: syntax error at end of input” for redshift query using JDBC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM