From: Date: June 27 2006 10:24pm Subject: Connector/J commit: r5445 - in branches/branch_5_1/connector-j: . src/com/mysql/jdbc src/testsuite/regression List-Archive: http://lists.mysql.com/commits/8350 X-Bug: 20687 Message-Id: <200606272024.k5RKO5XU030677@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/branch_5_1/connector-j/CHANGES branches/branch_5_1/connector-j/src/com/mysql/jdbc/Connection.java branches/branch_5_1/connector-j/src/testsuite/regression/StatementRegressionTest.java Log: Fixed BUG#20687 - Can't pool server-side prepared statements, exception raised when re-using them. Modified: branches/branch_5_1/connector-j/CHANGES =================================================================== --- branches/branch_5_1/connector-j/CHANGES 2006-06-27 20:13:53 UTC (rev 5444) +++ branches/branch_5_1/connector-j/CHANGES 2006-06-27 20:24:02 UTC (rev 5445) @@ -137,6 +137,9 @@ - Fixed BUG#20306 - ResultSet.getShort() for UNSIGNED TINYINT returns incorrect values when using server-side prepared statements. + - Fixed BUG#20687 - Can't pool server-side prepared statements, exception + raised when re-using them. + 05-26-06 - Version 3.1.13 - Fixed BUG#15464 - INOUT parameter does not store IN value. Modified: branches/branch_5_1/connector-j/src/com/mysql/jdbc/Connection.java =================================================================== --- branches/branch_5_1/connector-j/src/com/mysql/jdbc/Connection.java 2006-06-27 20:13:53 UTC (rev 5444) +++ branches/branch_5_1/connector-j/src/com/mysql/jdbc/Connection.java 2006-06-27 20:24:02 UTC (rev 5445) @@ -3603,8 +3603,8 @@ pStmt = (com.mysql.jdbc.ServerPreparedStatement)this.serverSideStatementCache.remove(sql); if (pStmt != null) { + ((com.mysql.jdbc.ServerPreparedStatement)pStmt).setClosed(false); pStmt.clearParameters(); - ((com.mysql.jdbc.ServerPreparedStatement)pStmt).setClosed(false); } } Modified: branches/branch_5_1/connector-j/src/testsuite/regression/StatementRegressionTest.java =================================================================== --- branches/branch_5_1/connector-j/src/testsuite/regression/StatementRegressionTest.java 2006-06-27 20:13:53 UTC (rev 5444) +++ branches/branch_5_1/connector-j/src/testsuite/regression/StatementRegressionTest.java 2006-06-27 20:24:02 UTC (rev 5445) @@ -3141,4 +3141,72 @@ } } + /** + * Tests fix for BUG#19615, PreparedStatement.setObject(int, Object, int) + * doesn't respect scale of BigDecimals. + * + * @throws Exception if the test fails. + */ + public void testBug19615() throws Exception { + createTable("testBug19615", "(field1 DECIMAL(19, 12))"); + + try { + BigDecimal dec = new BigDecimal("1.234567"); + + this.pstmt = this.conn.prepareStatement("INSERT INTO testBug19615 VALUES (?)"); + this.pstmt.setObject(1, dec, Types.DECIMAL); + this.pstmt.executeUpdate(); + this.pstmt.close(); + + + this.rs = this.stmt.executeQuery("SELECT field1 FROM testBug19615"); + this.rs.next(); + assertEquals(dec, this.rs.getBigDecimal(1).setScale(6)); + this.rs.close(); + this.stmt.executeUpdate("TRUNCATE TABLE testBug19615"); + + this.pstmt = ((com.mysql.jdbc.Connection)this.conn).clientPrepareStatement("INSERT INTO testBug19615 VALUES (?)"); + this.pstmt.setObject(1, dec, Types.DECIMAL); + this.pstmt.executeUpdate(); + this.pstmt.close(); + + + this.rs = this.stmt.executeQuery("SELECT field1 FROM testBug19615"); + this.rs.next(); + assertEquals(dec, this.rs.getBigDecimal(1).setScale(6)); + this.rs.close(); + } finally { + closeMemberJDBCResources(); + } + + } + + /** + * Fixes BUG#20687 - Can't pool server-side prepared statements, exception + * raised when re-using them. + * + * @throws Exception if the test fails. + */ + public void testBug20687() throws Exception { + createTable("testBug20687", "(field1 int)"); + Connection poolingConn = null; + + Properties props = new Properties(); + props.setProperty("cachePrepStmts", "true"); + + try { + poolingConn = getConnectionWithProps(props); + PreparedStatement pstmt1 = poolingConn.prepareStatement("SELECT field1 FROM testBug20687"); + pstmt1.executeQuery(); + pstmt1.close(); + + PreparedStatement pstmt2 = poolingConn.prepareStatement("SELECT field1 FROM testBug20687"); + pstmt2.executeQuery(); + assertSame(pstmt1, pstmt2); + pstmt2.close(); + } finally { + + } + } + }