@@ -12041,4 +12041,53 @@ public void testBug85317() throws Exception {
12041
12041
} while ((useSPS = !useSPS) || (rewriteBS = !rewriteBS));
12042
12042
12043
12043
}
12044
+
12045
+ /**
12046
+ * Tests fix for Bug#104349 (33563548), com.mysql.cj NPE.
12047
+ *
12048
+ * @throws Exception
12049
+ */
12050
+ @Test
12051
+ public void testBug104349() throws Exception {
12052
+ createTable("testBug104349", "(col1 INT, col2 VARCHAR(100))");
12053
+
12054
+ this.stmt.executeUpdate("INSERT INTO testBug104349 VALUES (1, 'key 1')");
12055
+ this.stmt.executeUpdate("INSERT INTO testBug104349 VALUES (2, 'key 2')");
12056
+ this.stmt.executeUpdate("INSERT INTO testBug104349 VALUES (3, 'key 3')");
12057
+
12058
+ Properties props = new Properties();
12059
+ props.setProperty(PropertyKey.useSSL.getKeyName(), "false");
12060
+ props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
12061
+ props.setProperty(PropertyKey.cachePrepStmts.getKeyName(), "true");
12062
+
12063
+ boolean useSPS = false;
12064
+ do {
12065
+ props.setProperty(PropertyKey.useServerPrepStmts.getKeyName(), "" + useSPS);
12066
+ Connection testConn = getConnectionWithProps(props);
12067
+
12068
+ PreparedStatement ps = testConn.prepareStatement("SELECT * FROM testBug104349 WHERE col1 = ?");
12069
+ assertTrue(ps.toString().endsWith("SELECT * FROM testBug104349 WHERE col1 = ** NOT SPECIFIED **"));
12070
+ ps.setInt(1, 1);
12071
+ assertTrue(ps.toString().endsWith("SELECT * FROM testBug104349 WHERE col1 = 1"));
12072
+ this.rs = ps.executeQuery();
12073
+ assertTrue(ps.toString().endsWith("SELECT * FROM testBug104349 WHERE col1 = 1"));
12074
+ while (this.rs.next()) {
12075
+ assertEquals(1, this.rs.getInt(1));
12076
+ assertEquals("key 1", this.rs.getString(2));
12077
+ }
12078
+ ps.close();
12079
+ ps = testConn.prepareStatement("SELECT * FROM testBug104349 WHERE col1 = ?");
12080
+ assertTrue(ps.toString().endsWith("SELECT * FROM testBug104349 WHERE col1 = ** NOT SPECIFIED **"));
12081
+ ps.setInt(1, 2);
12082
+ assertTrue(ps.toString().endsWith("SELECT * FROM testBug104349 WHERE col1 = 2"));
12083
+ this.rs = ps.executeQuery();
12084
+ assertTrue(ps.toString().endsWith("SELECT * FROM testBug104349 WHERE col1 = 2"));
12085
+ while (this.rs.next()) {
12086
+ assertEquals(2, this.rs.getInt(1));
12087
+ assertEquals("key 2", this.rs.getString(2));
12088
+ }
12089
+ testConn.close();
12090
+
12091
+ } while (useSPS = !useSPS);
12092
+ }
12044
12093
}
0 commit comments