After upgrading MySQL Connector/J from 9.4.0 to 9.5.0, connections to OceanBase (MySQL mode) work, but PreparedStatement queries return zero rows. The same SQL works with a plain Statement, and the same JDBC setup against MySQL 8 still works.
Environment
OceanBase CE 4.3.5.x (MySQL compatibility mode), Docker
SELECT VERSION();→5.7.25-OceanBase_CE 4.3.5.xConnector:
mysql-connector-j9.5.0JDBC URL includes
useServerPrepStmts=true
Table
CREATE TABLE jdbc_test (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
PRIMARY KEY (id)
);
INSERT INTO jdbc_test (id, name) VALUES (1, 'Jack');
Java
try (Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT name FROM jdbc_test WHERE id = 1")) {
while (rs.next()) {
System.out.println(rs.getString("name")); // prints Jack
}
}
try (Connection conn = ds.getConnection();
PreparedStatement ps = conn.prepareStatement("SELECT name FROM jdbc_test WHERE id = 1");
ResultSet rs = ps.executeQuery()) {
while (rs.next()) { // never enters loop
System.out.println(rs.getString("name"));
}
}
What I tried
Rolled back to 9.4.0 →
PreparedStatementworks againWith 9.5.0, setting
useServerPrepStmts=false→ also worksSELECT VERSION()always returns a row on 9.5.0; only tableSELECTqueries viaPreparedStatementseem affected.
Question: Is this a known interaction between Connector/J 9.5 server-side prepared statements and OceanBase’s MySQL protocol layer, or should I treat it as a driver config issue on my side?