Menu

#400 cannot insert null values via jTDS (regression from 374)

v2.5.*
closed-fixed
None
2.5.4
5
2017-07-23
2017-06-08
No

The fix for Bug [#374] has caused a regression that prevents DbUnit INSERT operations from inserting null values into a Microsoft SQL Server database using the jTDS driver.

As of Commit [6f7c2e], the addValue(Object,DataType) methods in the SimplePreparedStatement and PreparedBatchStatement classes now use a different overload of the JDBC PreparedStatement.setNull method, adding a string representation of the data type. However, since jTDS (as of 1.3.1) does not support the new variant of the setNull method, the whole thing falls over.

The workaround for me is to stay on dbUnit 2.5.2, as there really isn't a workaround within jTDS, and I'm not sure there is likely to be one in the near future. Is there any way of detecting and avoiding this error within dbUnit, and/or only using the three-parameter variant, PreparedStatement.setNull(int,int,String), where it is necessary? I realise that this might be a rare circumstance, but I don't really have time to try to fix this myself at the moment.

Any advice would be appreciated. :)

Related

Bugs: #374
Commit: [6f7c2e]

Discussion

  • Jeff Jensen

    Jeff Jensen - 2017-06-23

    It's regrettable when one fix creates another. And also regretfully no one has any advice for you!

    I'm open to ideas as well. My initial thought is a setting that disables/enables [#374] so it uses the non-breaking method call. Another thought is how to keep [#374] feature but implement differently so uses the original method.

    Best if we had a test that proves this problem.

     

    Related

    Bugs: #374

  • Jeff Jensen

    Jeff Jensen - 2017-06-23
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,6 +1,6 @@
    -The fix for Bug 374 has caused a regression that prevents DbUnit INSERT operations from inserting null values into a Microsoft SQL Server database using the jTDS driver.
    +The fix for Bug [#374] has caused a regression that prevents DbUnit INSERT operations from inserting null values into a Microsoft SQL Server database using the jTDS driver.
    
    -As of Commit 6f7c2e, the `addValue(Object,DataType)` methods in the `SimplePreparedStatement` and `PreparedBatchStatement` classes now use a different overload of the JDBC `PreparedStatement.setNull` method, adding a string representation of the data type. However, since jTDS (as of 1.3.1) does not support the new variant of the setNull method, the whole thing falls over.
    +As of Commit [6f7c2e], the `addValue(Object,DataType)` methods in the `SimplePreparedStatement` and `PreparedBatchStatement` classes now use a different overload of the JDBC `PreparedStatement.setNull` method, adding a string representation of the data type. However, since jTDS (as of 1.3.1) does not support the new variant of the setNull method, the whole thing falls over.
    
     The workaround for me is to stay on dbUnit 2.5.2, as there really isn't a workaround within jTDS, and I'm not sure there is likely to be one in the near future. Is there any way of detecting and avoiding this error within dbUnit, and/or only using the three-parameter variant, `PreparedStatement.setNull(int,int,String)`, where it is necessary? I realise that this might be a rare circumstance, but I don't really have time to try to fix this myself at the moment.
    
     

    Related

    Bugs: #374
    Commit: [6f7c2e]

  • Michal Šída

    Michal Šída - 2017-06-23

    See my comment in the related bug.

     
  • Michal Šída

    Michal Šída - 2017-07-20

    Some simple workarround (patch) prepared in the related bug.

     
    • Aaron Nielsen

      Aaron Nielsen - 2017-07-21

      I've built a JAR with that patch applied and I don't get the same error from jTDS. I haven't tested this thoroughly, but at first glance, it's working for me.

       
      • Jeff Jensen

        Jeff Jensen - 2017-07-23

        Thank you Michal for providing the fix and thank you Aaron for testing it.

         
  • Jeff Jensen

    Jeff Jensen - 2017-07-23
    • status: open --> closed-fixed
    • assigned_to: Jeff Jensen
    • Fixed Release: (not fixed) --> 2.5.4
     

Log in to post a comment.