Skip to content

Commit

Permalink
Fix MySQL metadata when prepared statement caching is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Nov 4, 2024
1 parent 0515330 commit b47eed1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@
"allPublicConstructors": true,
"name": "com.mysql.cj.exceptions.InvalidConnectionAttributeException"
},
{
"condition": {
"typeReachable": "com.mysql.cj.jdbc.ConnectionImpl"
},
"allPublicConstructors": true,
"name": "com.mysql.cj.PerConnectionLRUFactory"
},
{
"condition": {
"typeReachable": "com.mysql.cj.protocol.ExportControlled"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.Duration;
import java.util.Collections;
import java.util.Map;
import java.util.Properties;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;

/**
* This test uses docker to start a MySQL database to test against.
Expand All @@ -40,9 +43,14 @@ public class MySQLTests {
private static Process process;

private static Connection openConnection() throws SQLException {
return openConnection(Collections.emptyMap());
}

private static Connection openConnection(Map<String, String> additionalProperties) throws SQLException {
Properties props = new Properties();
props.setProperty("user", USERNAME);
props.setProperty("password", PASSWORD);
props.putAll(additionalProperties);
return DriverManager.getConnection(JDBC_URL, props);
}

Expand Down Expand Up @@ -139,4 +147,10 @@ void simpleDatatypes() throws Exception {
}
}
}

@Test
void preparedStatementCaching() {
assertThatNoException().isThrownBy(() -> openConnection(Map.of("cachePrepStmts", "true")).close());
}

}

0 comments on commit b47eed1

Please sign in to comment.