Bug #37645 java.sql.PreparedStatement.close() causes IllegalArgumentException
Submitted: 25 Jun 2008 22:08 Modified: 5 Sep 2008 19:40
Reporter: Yevgeny Shakhnovich Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S1 (Critical)
Version:5.1.6 OS:Any
Assigned to: CPU Architecture:Any

[25 Jun 2008 22:08] Yevgeny Shakhnovich
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.
[28 Jun 2008 18:07] Sveta Smirnova
Thank you for the report.

I can not repeat described behavior. Please provide example of code problem is repeatable with.
[28 Jul 2008 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[30 Jul 2008 17:01] Erik Hansen
I am seeing this same problem.

JBoss 4.2.2 with MySQL set up as an XA datasource with Connector/J 5.1.6 this is happening 100% of the time for me.

Caused by: 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)
	at org.jboss.resource.adapter.jdbc.WrappedStatement.internalClose(WrappedStatement.java:590)
	at org.jboss.resource.adapter.jdbc.WrappedStatement.close(WrappedStatement.java:75)
	at org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:534)
	at org.hibernate.jdbc.AbstractBatcher.closeStatement(AbstractBatcher.java:269)
	at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:285)
	at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:212)

Connector/J 5.0.6 does not exhibit this problem.
[22 Aug 2008 9:39] Eirik Stenersen Sand
I have the same problem.

* jdk 1.6
* mysql-connector-java-5.1.6
* commons-dbcp-1.2.2

Every call to preparedStatment.close() results in:

java.lang.IllegalArgumentException: null source
[27 Aug 2008 14:14] Karol Bienkowski
I had the same problem when connecting to an XA datasource on JBoss using mysql-connector-java-5.1.6. The MySQL server was 5.0.24-community-nt. 

Switching to mysql-connector-java-5.0.8 helped immediately. I think that the 5.0 connector is suitable only for the 5.0 MySQL server. Please check your server version and try to downgrade.

I also found that <track-connection-by-tx/> is necessary in the <xa-datasource> definition on JBoss to make the XA datasource working.
[29 Aug 2008 15:43] Chris Webster
Seems like this is a duplicate of: http://bugs.mysql.com/bug.php?id=38699
[1 Sep 2008 6:11] Sveta Smirnova
Yevgeny,

please try latest 5.1 snapshot too. You can download it from http://downloads.mysql.com/snapshots.php
[1 Sep 2008 18:11] Tonci Grgin
Bug#38699 is closed now, probably same thing will work for this report too.
[5 Sep 2008 14:40] Yevgeny Shakhnovich
Yes, I confirm that it is fixed. Thank you.
[5 Sep 2008 19:40] Sveta Smirnova
Thank you for the feedback.

I close this report as duplicate of Bug#38699, because it is confirmed now.