Skip to content

"Parameter metadata not available for the given statement" SQL Exception after upgrading to Spring 5.0 RC4 [SPR-15977] #20528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Sep 19, 2017 · 4 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: regression A bug that is also a regression
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Sep 19, 2017

Bogdan Dumitrescu opened SPR-15977 and commented

Scenario:

  • execute a prepared statement using JdbcTemplate inserting a row into MySQL 5.5:

jdbcTemplate.update("insert into users (id, name, description) values (?, ?, ?)", id, name, description);

  • 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


Affects: 5.0 RC4

Attachments:

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Sep 19, 2017

Juergen Hoeller commented

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.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

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...

@spring-projects-issues
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

2 participants