When upgrading from Spring 3.2.0 to Spring 4.0.0 we suddenly get the following exception.
The tracked the issue down to:
- StatementCreatorUtils now calls PreparedStatement#getParameterMetaData() for null bind parameters
- PreparedStatement#getParameterMetaData() throws an java.lang.ArrayIndexOutOfBoundsException if the SQL query contains a comment
- the JBoss connection pool (IronJacamar) disassociates the PreparedStatement with the connection
- StatementCreatorUtils swallows the exception and goes on to call PreparedStatement#setNull()
- the JBoss connection pool throws an exception because the PreparedStatement is no longer valid
The issue can be reproduced with the following code.
The quick fix we currently use is add "Oracle JDBC driver" to StatementCreatorUtils#driversWithNoSupportForGetParameterTypes through reflection but this is a hack at best.
Not using comments is not an option for us as we tag most of our queries with comments for monitoring in Enterprise Manager Cloud Control.
Not using null is not always easy as sometimes we have dynamic SQL where it's just easier to use NVL or IS NULL instead of several different queries.
We're aware that this is actually an Oracle bug and not a Spring bug but we need a better work around until we get a fix from Oracle. We're aware that JBoss actually certified the 12c driver.
- Java 7u45
- ojdbc7 188.8.131.52
- JBoss EAP 6.1.0