Bug #5188 | CachedRowSet errors using PreparedStatement | ||
---|---|---|---|
Submitted: | 24 Aug 2004 18:44 | Modified: | 28 Aug 2004 0:03 |
Reporter: | Ian Brandon | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 4.1.3b | OS: | Linux (Linux Fedora core 1) |
Assigned to: | Eric Herman | CPU Architecture: | Any |
[24 Aug 2004 18:44]
Ian Brandon
[24 Aug 2004 18:51]
Ian Brandon
ps the snippet is just a guideline - I appreciate scrolling thru' the CachedRowSet should be of the form if (crs.next()){ ..
[24 Aug 2004 18:57]
Ian Brandon
One more thing - I'm using Connector J 3.13 beta...
[24 Aug 2004 19:21]
Ian Brandon
finally - the java platform = j2sdk1.4.2_04, IDE = netbeans 3.5.1 (uses tomcat 4.0..)
[27 Aug 2004 23:56]
Eric Herman
I could not repeat this bug within a *very* similar environment. * MySQL version 4.1.3b * java java version "1.4.2_05" * Linux Mandrake 10.0 Because attempting to reproduce this bug requires the Sun reference implementation, I will not be checking this into the codebase. However I've included it here for review: /** * Tests fix for BUG#5188, CachedRowSet errors using PreparedStatement. * * @throws Exception */ public void testBug5188() throws Exception { try { this.stmt.executeUpdate("DROP TABLE IF EXISTS testBug5188"); this.stmt.executeUpdate("CREATE TABLE testBug5188 " + "(ID int NOT NULL AUTO_INCREMENT, " + "datafield VARCHAR(64), " + "PRIMARY KEY(ID))"); this.stmt.executeUpdate("INSERT INTO testBug5188(datafield) " + "values('test data stuff !')"); CachedRowSetImpl crs = null; String sql = "SELECT * FROM testBug5188 where ID = ?"; pstmt = conn.prepareStatement(sql); pstmt.setString(1, "1"); rs = pstmt.executeQuery(); // create a CachedRowSet and populate it crs = new CachedRowSetImpl(); crs.populate(rs); // scroll through CachedRowSet & return results to screen ... assertTrue(crs.next()); assertEquals("1", crs.getString("ID")); assertEquals("test data stuff !", crs.getString("datafield")); assertFalse(crs.next()); } finally { this.stmt.executeUpdate("DROP TABLE IF EXISTS testBug5188"); } }
[28 Aug 2004 0:03]
Eric Herman
One notable difference: I ran the test using the latest Connector/J 3.1 from source control, not a tagged version.
[29 Aug 2004 12:05]
Ian Brandon
Yes thanks Eric ! .. looks like it was the Connector / J 3.1 beta. Following your tip I tried using Connector J 3.014 *production ver.* instead (I'm not sure how to get stuff from 'source control') and it worked !!