Results 1 to 3 of 3

Thread: How to pass null to SqlUpdate.update

  1. #1
    Join Date
    Sep 2004
    Posts
    2

    Default How to pass null to SqlUpdate.update

    Hi all,


    I'm new to Spring, but as far as it goes, I like it.

    I have a couple question here, hope you can help me out.

    1. I tried to update a row in database using SqlUpdate.update(object[]) method. Since some of the field in the row may not be set, sometimes some field in input array will be null.
    When I execute the code I got exception saying "Driver not capable". I figure out that it only happen when any of the parameter i passed to update([]) method was null.
    The field that was null does not have NOT NULL constrain in DB. And it works If I modified the sql and put "null" in the sql string where the value should have been.

    I know that if I set the PreparedStatement directly I can use its setNull() method. However, that seems like a hack to me. Another place I look is PreparedStatementSetter but i don't think that's the right way.

    I use JdbcOdbc pooled with DBCP with FireBird DB.


    2. Currently, When I want to do query, I subclass all my query from MAppingSqlQuery. And When I want to do Update, Insert or Delete, I subclass then from SqlUpdate.
    Is this what I should be doing. Or is it any better pattern you would use. Many people in here seems to use JDbcTemplate Directly.


    Thanks

  2. #2
    Join Date
    Aug 2004
    Posts
    1,104

    Default

    1. From what you describe, it sounds like it is a driver problem. I'm not sure why you are using JdbcOdbc driver. Doesn't FireBird have a JdbcDriver? Could you post some code and a debug log?

    2. Both approaches are valid and I tend to subclass MappingSqlQuery for more complex queries and use JdbcTemplate for simpler stuff.
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  3. #3
    Join Date
    Sep 2004
    Posts
    2

    Default

    Yes, It is indeed a driver problem. I switched to use Jaybird Jdbc and it works fine.

    A little on going question here.
    For all those SQLupdate or JDbcTemplate, does it automatically do rollback in case of Exception?

Similar Threads

  1. Replies: 2
    Last Post: Oct 17th, 2005, 08:41 PM
  2. Replies: 2
    Last Post: Oct 13th, 2005, 02:47 PM
  3. Replies: 4
    Last Post: Sep 27th, 2005, 11:31 PM
  4. Replies: 3
    Last Post: May 16th, 2005, 07:04 AM
  5. Strange Data Access Error
    By webifyit in forum Data
    Replies: 2
    Last Post: Dec 28th, 2004, 11:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •