Results 1 to 7 of 7

Thread: TYPES.null error with Spring/MS SQL server jdbc driver configuration

  1. #1

    Default TYPES.null error with Spring/MS SQL server jdbc driver configuration

    When setNull() is called with second parameter Types.NULL, it causes a null pointer exception in the MS JDBC driver. Configuration: SQL server 2005 SP2, MS JDBC driver 1.1, Spring 1.2.8. This is used as setNull(paramIndex, Types.NULL) in the class org.springframework.jdbc.core.StatementCreatorUtil s; also please see: http://forums.microsoft.com/MSDN/Sho...67342&SiteID=1 for details.

    Stack trace below:
    java.lang.NullPointerException

    at com.microsoft.sqlserver.jdbc.AppDTVImpl$SetValueOp .executeDefault(Unknown Source)
    at com.microsoft.sqlserver.jdbc.DTV.executeOp(Unknown Source)
    at com.microsoft.sqlserver.jdbc.AppDTVImpl.setValue(U nknown Source)
    at com.microsoft.sqlserver.jdbc.DTV.setValue(Unknown Source)
    at com.microsoft.sqlserver.jdbc.Parameter.setValue(Un known Source)
    at com.microsoft.sqlserver.jdbc.Parameter.setValue(Un known Source)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStat ement.setNull(Unknown Source)
    at org.apache.commons.dbcp.DelegatingPreparedStatemen t.setNull(DelegatingPreparedStatement.java:104)
    at org.springframework.jdbc.core.StatementCreatorUtil s.setParameterValue(StatementCreatorUtils.java:96)
    at org.springframework.jdbc.core.JdbcTemplate$ArgPrep aredStatementSetter.setValues(JdbcTemplate.java:11 81)
    at org.springframework.jdbc.core.JdbcTemplate$2.doInP reparedStatement(JdbcTemplate.java:695)
    at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:476)
    at org.springframework.jdbc.core.JdbcTemplate.update( JdbcTemplate.java:691)
    at org.springframework.jdbc.core.JdbcTemplate.update( JdbcTemplate.java:753)
    at org.springframework.jdbc.core.JdbcTemplate.update( JdbcTemplate.java:761)

    Any workarounds for this?

    Thanks,
    sm.

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

    Default

    Have you tried explicitly providing an array of the java.sql.Type for each parameter using the "int update(String sql, Object[] args, int[] argTypes)" method?
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  3. #3

    Default

    That worked, thanks.

  4. #4
    Join Date
    Feb 2007
    Location
    Hannover, Germany
    Posts
    20

    Default

    Quote Originally Posted by sm_springframework View Post
    That worked, thanks.
    Spring 2.0.6 has the same issue and the same solution works. Thank you for your help, Thomas!

    Unfortunately, this means that you can't use the "new" SimpleJdbcTemplate for updates if you depend on the recent MS JDBC-Driver 1.1.

    jiai

  5. #5
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    You could always give jTDS a try instead of the MS driver, this might behave differently.
    Last edited by karldmoore; Aug 29th, 2007 at 10:26 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  6. #6
    Join Date
    Feb 2007
    Location
    Hannover, Germany
    Posts
    20

    Default

    Quote Originally Posted by karldmoore View Post
    You could always give jTDS a try instead of the MS driver, this might behave differently.
    jTDS behaves differently (and works) - as "sm" describes in his post on the Microsoft forum.
    Unfortunately, jTDS doesn't support connection pooling as denoted in the FAQ.

    jiai

  7. #7
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Quote Originally Posted by jiai View Post
    jTDS behaves differently (and works) - as "sm" describes in his post on the Microsoft forum.
    Ok that will teach me for not reading that .

    Quote Originally Posted by jiai View Post
    Unfortunately, jTDS doesn't support connection pooling as denoted in the FAQ.
    Can't you just use DBCP or c3p0 to provide this instead?
    Last edited by karldmoore; Aug 29th, 2007 at 10:26 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

Posting Permissions

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