Bug #62445 Mysql report IllegalArgument exception while closing statement
Submitted: 16 Sep 2011 0:49 Modified: 26 Sep 2011 7:25
Reporter: Yaffle Shi Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.17 OS:Linux
Assigned to: CPU Architecture:Any

[16 Sep 2011 0:49] Yaffle Shi
Description:
Error closing statement Caused by: 
java.lang.IllegalArgumentException: null source
	at java.util.EventObject.<init>(EventObject.java:56)
	at javax.sql.StatementEvent.<init>(StatementEvent.java:64)
	at com.mysql.jdbc.jdbc2.optional.JDBC4PreparedStatementWrapper.close(JDBC4PreparedStatementWrapper.java:70)
	at org.jboss.resource.adapter.jdbc.WrappedStatement.internalClose(WrappedStatement.java:881)
	at org.jboss.resource.adapter.jdbc.WrappedStatement.close(WrappedStatement.java:79)

How to repeat:
A lot of places in my application shows this exception.

Suggested fix:
This issue happens in version 5.1.6 as described in bug 37645. I'm not sure whether it's broken again or not. Below are some comments I found from that bug:

Description:
Invocation of PreparedStatement.close() always causes IllegalArgumentException;

java.lang.IllegalArgumentException: null source
	at java.util.EventObject.<init>(EventObject.java:38)
	at javax.sql.StatementEvent.<init>(StatementEvent.java:39)
	at
com.mysql.jdbc.jdbc2.optional.JDBC4PreparedStatementWrapper.close(JDBC4PreparedStatementWrapper.java:70)

The problem is pretty simple. JDBC4PreparedStatementWrapper.close() calls
StatementWrapper.close() where pooledConnection is set to null. Then
JDBC4PreparedStatementWrapper.close() tries to fire javax.sql.StatementEvent with null
PooledConnection as a parameter. It triggers the exception. 

How to repeat:
Easy. Create a PreparedStatement and close it.
[26 Sep 2011 7:25] Tonci Grgin
Same problem reported in Bug#62452.