Skip to content

Commit 1cf0719

Browse files
fjssilvaAxyoan Marcelo
authored andcommitted
Fix for Bug#22473405, GETOBJECT(STRING , CLASS<T>) METHOD RETURNS ERROR FOR POOLED CONNECTION.
Change-Id: I94a059abeeb5b242c03536a9c84cd8df4aed6bbe
1 parent 185648f commit 1cf0719

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
Version 9.4.0
55

6+
- Fix for Bug#22473405, GETOBJECT(STRING , CLASS<T>) METHOD RETURNS ERROR FOR POOLED CONNECTION.
7+
68
- WL#17009, Upgrade 3rd party libraries and tools.
79

810
- Fix for Bug#118201 (Bug#37971552), A potential bug in Mysql Connector/J.

src/main/user-impl/java/com/mysql/cj/jdbc/CallableStatementWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ public void setNClob(String parameterName, Reader reader) throws SQLException {
17171717
@Override
17181718
public <T> T getObject(int parameterIndex, Class<T> type) throws SQLException {
17191719
if (this.wrappedStmt != null) {
1720-
return null; // TODO
1720+
return ((CallableStatement) this.wrappedStmt).getObject(parameterIndex, type);
17211721
}
17221722
throw SQLError.createSQLException(Messages.getString("Statement.AlreadyClosed"), MysqlErrorNumbers.SQLSTATE_CONNJ_GENERAL_ERROR,
17231723
this.exceptionInterceptor);
@@ -1726,7 +1726,7 @@ public <T> T getObject(int parameterIndex, Class<T> type) throws SQLException {
17261726
@Override
17271727
public <T> T getObject(String parameterName, Class<T> type) throws SQLException {
17281728
if (this.wrappedStmt != null) {
1729-
return null; // TODO
1729+
return ((CallableStatement) this.wrappedStmt).getObject(parameterName, type);
17301730
}
17311731
throw SQLError.createSQLException(Messages.getString("Statement.AlreadyClosed"), MysqlErrorNumbers.SQLSTATE_CONNJ_GENERAL_ERROR,
17321732
this.exceptionInterceptor);

src/test/java/testsuite/regression/CallableStatementRegressionTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import com.mysql.cj.conf.PropertyKey;
5353
import com.mysql.cj.exceptions.MysqlErrorNumbers;
5454
import com.mysql.cj.jdbc.JdbcConnection;
55+
import com.mysql.cj.jdbc.MysqlConnectionPoolDataSource;
5556
import com.mysql.cj.util.StringUtils;
5657

5758
import testsuite.BaseTestCase;
@@ -2105,4 +2106,27 @@ void testBug20279578() throws Exception {
21052106
}
21062107
}
21072108

2109+
/**
2110+
* Tests fix for Bug#22473405, GETOBJECT(STRING , CLASS<T>) METHOD RETURNS ERROR FOR POOLED CONNECTION.
2111+
*
2112+
* @throws Exception
2113+
*/
2114+
@Test
2115+
void testBug22473405() throws Exception {
2116+
createProcedure("testBug22473405", "(OUT p INT) BEGIN SELECT 1 INTO p; END");
2117+
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
2118+
ds.setURL(dbUrl);
2119+
Connection testConn = ds.getPooledConnection().getConnection();
2120+
2121+
CallableStatement cstmt = testConn.prepareCall("{CALL testBug22473405(?)}");
2122+
cstmt.registerOutParameter(1, java.sql.Types.INTEGER);
2123+
cstmt.execute();
2124+
assertEquals(1, cstmt.getObject(1, Integer.class));
2125+
2126+
cstmt = testConn.prepareCall("{CALL testBug22473405(?)}");
2127+
cstmt.registerOutParameter(1, java.sql.Types.INTEGER);
2128+
cstmt.execute();
2129+
assertEquals(1, cstmt.getObject(1, Integer.class));
2130+
}
2131+
21082132
}

0 commit comments

Comments
 (0)