Skip to content

NamedParameterJdbcTemplate for "insert / select" clause, set NULL value causes JConnect 7 (Sybase) problem - java.io.IOException: JZ0SL: Unsupported SQL type 0. - Affects 3.1.3.RELEASE, works in 3.1.1.RELEASE [SPR-10084] #14717

Closed

Description

@spring-projects-issues

David Boden opened SPR-10084 and commented

On a SQL query that involves:

insert into AbcTable
select :param1, :param2, otherValue
from DefTable

... using a NamedParameterJdbcTemplate and mapping one of the named parameters to NULL in the parameter map results in:
java.io.IOException: JZ0SL: Unsupported SQL type 0.

Example code (Spring 3.1.3.RELEASE):
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("param1", null);
template.update(insertSql, parameters);

Works (inserts a null value into the table) in 3.1.1.RELEASE.

Using Sybase JConnect 7.07.ESD5 (latest) and other versions of JConnect spanning back 2 years.

Test details to follow on Monday, just wanted to raise the issue.


Affects: 3.1.3

Issue Links:

Referenced from: commits f449b5a, f0a1ff2

Backported to: 3.1.4

Activity

  1. spring-projects-issues commented on Dec 10, 2012

    @spring-projects-issues
    CollaboratorAuthor

    David Boden commented

    Looks like the problem is caused by the range of Sybase JConnect 7 drivers that I've tried not behaving correctly when PreparedStatement.getParameterMetaData() is called.

    StatementCreatorUtils line 234 is:
    pmd = ps.getParameterMetaData();

    JConnect 7 throws:
    com.sybase.jdbc4.jdbc.SybSQLException: Incorrect syntax near the keyword 'select'.

    This may be due to a misconfiguration on the server side but:

    • We've used the most recent JConnect server-side scripts and they executed successfully.
    • All other database operations work fine.

    The line is already inside a try/catch. I'd appreciate it if a defensive "catch(SQLException ex)" could be added alongside the existing "catch (AbstractMethodError err)". That would return things to the 3.1.1.RELEASE behaviour for me.

  2. spring-projects-issues commented on Dec 10, 2012

    @spring-projects-issues
    CollaboratorAuthor

    David Boden commented

    I've confirmed that this is a bug with Sybase JConnect and have filed a bug report with Sybase. I'll ask them to make the bug report public and will specify the bug tracker id on here for reference.

    But... I could still do with the defensive "catch(SQLException ex)" to restore the previous behaviour in spite of this Sybase bug.

  3. spring-projects-issues commented on Dec 12, 2012

    @spring-projects-issues
    CollaboratorAuthor

    David Boden commented

    Sybase Case# 11766880

  4. spring-projects-issues commented on Dec 12, 2012

    @spring-projects-issues
    CollaboratorAuthor

    Chris Beams commented

    Thanks, David for following up here. Please consider submitting a pull request for this per the instructions at https://github.com/SpringSource/spring-framework/blob/master/CONTRIBUTING.md. Otherwise we'll get to it as we can, thanks.

  5. spring-projects-issues commented on Dec 31, 2012

    @spring-projects-issues
    CollaboratorAuthor

    David Boden commented

    Apologies, thought I already commented on this one... I've confirmed that this is fixed in 3.2.0.RELEASE ! Would appreciate it if you could close this Jira for me.

  6. spring-projects-issues commented on Dec 31, 2012

    @spring-projects-issues
    CollaboratorAuthor

    Chris Beams commented

    Hi David,

    Resolving as requested, but note that we haven't made any changes to the framework regarding this problem. Perhaps it's environmental, or a function of an upgraded Sybase driver that it's now working. In any case, thanks for the update.

  7. spring-projects-issues commented on Dec 31, 2012

    @spring-projects-issues
    CollaboratorAuthor

    David Boden commented

    Thanks Chris. I see differences between the 3.1.3 and 3.2.0 StatementUtils.java file in Maven Central:

    Specifically, these lines are missing from 3.2.0. Perhaps this is a regression (changes were meant to be applied to 3.2.0 but weren't)?

    ParameterMetaData pmd = null;
    try {
             pmd = ps.getParameterMetaData();
    }
    catch (AbstractMethodError err) {
             // JDBC driver not compliant with JDBC 3.0
             // -> proceed with database-specific checks
    }
    if (pmd != null) {
             sqlType = pmd.getParameterType(paramIndex);
    }
    else {
  8. spring-projects-issues commented on Jan 7, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Chris Beams commented

    Thanks, David. Will look back into this.

  9. spring-projects-issues commented on Jan 10, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Indeed, I've accidentally applied this to the 3.1.x branch only. To be fixed for 3.2.1.

    Juergen

  10. spring-projects-issues commented on Jan 11, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Chris Beams commented

    Looks like this showed up in 3.1.x with commit 79d9f7a5f731268a4a999ce45e0579f3c512a2f6.

  11. spring-projects-issues commented on Jan 11, 2013

    @spring-projects-issues
    CollaboratorAuthor

    David Boden commented

    Thanks. This is probably obvious to you, but just wanted to make it clear that applying the patch as-is to the 3.2.x codebase will introduce the problem I've reported to the 3.2.x branch too. Hopefully this Jira represents fixing the current on the 3.1 stream and applying both the original commit and the fix to the 3.2 stream?

  12. spring-projects-issues commented on Jan 11, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Applied to both branches with minor modifications for defensiveness against the JDBC driver now, as you suggested above.

    Juergen

  13. added
    type: bug
    in: data
    status: backported
    on Jan 11, 2019
  14. added this to the 3.2.1 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: datastatus: backportedtype: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions