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. I've followed a few tutorials to get MySQL working with the JDBC driver. 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. Despite these versions, I keep getting this error: 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!
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.
I have JDBC 8.0.21 installed and the MySQL database is in 8.0.13-4
(I presume you mean 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.
It is most likely caused your application (e.g. executing a SET GLOBAL query_cache_size=... or similar) or a stray / outdated option in the JDBC url that your application is using when connecting to the database.