You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Parameter metadata not available for the given statement" SQL Exception after upgrading to Spring 5.0 RC4 [SPR-15977] #20528
condition to reproduce: one of the arguments of the prepared statement is null. The column definition in MySQL corresponding to the null argument accepts null values.
When trying to execute the above with Spring 5.0 RC4 we are getting a "java.sql.SQLException: Parameter metadata not available for the given statement".
The same code executes fine when using the 4.3.11.RELEASE of spring-jdbc.
Using version 5.1.44 of mysql-connector-java, we're seeing the same behaviour on the following MySQL versions:
Ver 14.14 Distrib 5.5.53
Ver 14.14 Distrib 5.7.18-15
Could you post the stacktrace for the underlying SQLException as well, please? I'm pretty sure this is a side effect of #18399 but it'd be great to know where exactly it originates... It's probably in StatementCreatorUtils.setNull but it'd be great to double-check.
I've reintroduced a catch block around our getParameterType call in StatementCreatorUtils.setNull which I'm pretty sure is the root cause here. Spring Framework 4.x had a defensive catch block there against older JDBC drivers which implicitly covered this but got removed in the JDBC baseline upgrade for 5.0. Now it's not about general lack of support for getParameterType but rather just about failing for specific statements, so it should be sufficient to simply locally catch and log the SQLException and proceed with our fallback code path.
To be committed and backported tomorrow. It would nevertheless be great to verify that this matches your particular case...
First of all, thank you for fixing this so quickly!
I've added the stack trace from the underlying SQLException, just for completeness. We were using mysql-connector 5.1.36 for this stack trace, but we reproduced the error after upgrading to 5.1.44 as well.
I'll test your fix as it's backported and let you know. Thanks again!
I can confirm that with the latest 5.0 snapshot build our problem is solved - the row with null values is successfully saved to the database. Thank you!
Activity
spring-projects-issues commentedon Sep 19, 2017
Juergen Hoeller commented
Could you post the stacktrace for the underlying
SQLExceptionas well, please? I'm pretty sure this is a side effect of #18399 but it'd be great to know where exactly it originates... It's probably inStatementCreatorUtils.setNullbut it'd be great to double-check.spring-projects-issues commentedon Sep 19, 2017
Juergen Hoeller commented
I've reintroduced a catch block around our
getParameterTypecall inStatementCreatorUtils.setNullwhich I'm pretty sure is the root cause here. Spring Framework 4.x had a defensive catch block there against older JDBC drivers which implicitly covered this but got removed in the JDBC baseline upgrade for 5.0. Now it's not about general lack of support forgetParameterTypebut rather just about failing for specific statements, so it should be sufficient to simply locally catch and log theSQLExceptionand proceed with our fallback code path.To be committed and backported tomorrow. It would nevertheless be great to verify that this matches your particular case...
spring-projects-issues commentedon Sep 20, 2017
Bogdan Dumitrescu commented
First of all, thank you for fixing this so quickly!
I've added the stack trace from the underlying SQLException, just for completeness. We were using mysql-connector 5.1.36 for this stack trace, but we reproduced the error after upgrading to 5.1.44 as well.
I'll test your fix as it's backported and let you know. Thanks again!
spring-projects-issues commentedon Sep 20, 2017
Bogdan Dumitrescu commented
I can confirm that with the latest 5.0 snapshot build our problem is solved - the row with null values is successfully saved to the database. Thank you!