| Bug #3252 | Statement.getWarnings() not as specifiy in JDBC | ||
|---|---|---|---|
| Submitted: | 22 Mar 2004 0:39 | Modified: | 22 Mar 2004 6:10 |
| Reporter: | Klaus Halfmann | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / J | Severity: | S3 (Non-critical) |
| Version: | mysql-connector-java-3.0.11-stable | OS: | Windows (WindowsXP) |
| Assigned to: | Mark Matthews | CPU Architecture: | Any |
[22 Mar 2004 6:10]
Mark Matthews
The warning chain is never really set in Connector/J 3.0.x, because MySQL itself (at the point when Connector/J 3.0.x was feature frozen) did not support warnings. Therefore, the code was never completed. Warning support is in Connector/J 3.1.x.

Description: The JDBC API (jdk1.4.2/docs/api/java/sql/Statement.html#getWarnings()) says: public SQLWarning getWarnings() throws SQLException Retrieves the first warning reported by calls on this Statement object. Subsequent Statement object warnings will be chained to this SQLWarning object. The code I decompile from the driver reads: public synchronized SQLWarning getWarnings() throws SQLException { return warningChain; } but the warningChain is only set on public synchronized void clearWarnings() throws SQLException { warningChain = pendingWarnings; pendingWarnings = null; } Which is called before executing any statements. So the code will only return warnings from the previous Statment. How to repeat: I dont know how to generate a warning with MySQL, yet, so I cannot actually test this (pseudo) code, sorry. Statement stm = connection.createStatement(); stm.execute("... <SQL WITH WARNINGS>..."); assertNotNull(stm.getWarnings()); stm.execute"... <SQL WITHOUT WARNINGS>..."); assertNull(stm.getWarnings()); Suggested fix: The code above should work as expected.