Skip to content

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

Closed

Description

@spring-projects-issues

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:

Activity

  1. spring-projects-issues commented on Sep 19, 2017

    @spring-projects-issues
    CollaboratorAuthor

    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.

  2. spring-projects-issues commented on Sep 19, 2017

    @spring-projects-issues
    CollaboratorAuthor

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

  3. spring-projects-issues commented on Sep 20, 2017

    @spring-projects-issues
    CollaboratorAuthor

    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!

  4. spring-projects-issues commented on Sep 20, 2017

    @spring-projects-issues
    CollaboratorAuthor

    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!

  5. added
    type: regression
    in: data
    on Jan 11, 2019
  6. added this to the 5.0 GA milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: datatype: regression

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions