Skip to content

Commit 7305228

Browse files
authored
Fix MySQL metadata when prepared statement caching is enabled (#559)
Fixes gh-549
1 parent b8d1645 commit 7305228

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

metadata/com.mysql/mysql-connector-j/8.0.31/reflect-config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@
118118
"allPublicConstructors": true,
119119
"name": "com.mysql.cj.exceptions.InvalidConnectionAttributeException"
120120
},
121+
{
122+
"condition": {
123+
"typeReachable": "com.mysql.cj.jdbc.ConnectionImpl"
124+
},
125+
"allPublicConstructors": true,
126+
"name": "com.mysql.cj.PerConnectionLRUFactory"
127+
},
121128
{
122129
"condition": {
123130
"typeReachable": "com.mysql.cj.protocol.ExportControlled"

tests/src/com.mysql/mysql-connector-j/8.0.31/src/test/java/mysql/MySQLTests.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020
import java.sql.ResultSet;
2121
import java.sql.SQLException;
2222
import java.time.Duration;
23+
import java.util.Collections;
24+
import java.util.Map;
2325
import java.util.Properties;
2426

2527
import static org.assertj.core.api.Assertions.assertThat;
28+
import static org.assertj.core.api.Assertions.assertThatNoException;
2629

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

4245
private static Connection openConnection() throws SQLException {
46+
return openConnection(Collections.emptyMap());
47+
}
48+
49+
private static Connection openConnection(Map<String, String> additionalProperties) throws SQLException {
4350
Properties props = new Properties();
4451
props.setProperty("user", USERNAME);
4552
props.setProperty("password", PASSWORD);
53+
props.putAll(additionalProperties);
4654
return DriverManager.getConnection(JDBC_URL, props);
4755
}
4856

@@ -139,4 +147,10 @@ void simpleDatatypes() throws Exception {
139147
}
140148
}
141149
}
150+
151+
@Test
152+
void preparedStatementCaching() {
153+
assertThatNoException().isThrownBy(() -> openConnection(Map.of("cachePrepStmts", "true")).close());
154+
}
155+
142156
}

0 commit comments

Comments
 (0)