Bug #2957 getStatement returns null for ResultSet returned by getGeneratedKeys
| Submitted: | 25 Feb 2004 7:47 | Modified: | 5 Mar 2004 14:24 |
|---|---|---|---|
| Reporter: | [ name withheld ] | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / J | Severity: | S3 (Non-critical) |
| Version: | 3.0.10 | OS: | |
| Assigned to: | Mark Matthews | CPU Architecture: | Any |
[5 Mar 2004 14:24]
Mark Matthews
This will end up in 3.0.12. You can check out a nightly snapshot from http://downloads.mysql.com/snapshots.php if you need to test it earlier.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.063 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: The JDBC specification isn't clear on this, but I'd have expected the fragment in the 'how to repeat' field below to work. At the moment the result set returned by the getGeneratedKeys call doesn't know what it's owning statement is, so the final stmt.close() will throw a NullPointerException. How to repeat: stmt = conn.prepareStatement("insert into ...", Statement.RETURN_GENERATED_KEYS); ... stmt.execute(); rs = stmt.getGeneratedKeys(); ... stmt = rs.getStatement(); stmt.close(); Suggested fix: com/mysql/jdbc/Statement.java:getGeneratedKeys perhaps ought to call 'setStatement' after it creates the ResultSet, if that's the correct interpretation of the JDBC 3.0 spec.