• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How does PreparedStatement.setObject() API behaves with null value?

 
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How does PreparedStatement.setObject() API behaves with null value?
For e.g. If i have

would the null passed in setObject is tranlated as SQL data type Null always? or do i have to use setNull() API?
JDBC 3.0 spec says that,


(section 13.2.2) a value must be provided (setXXX()). if the value is not set, then a SQLException should be thrown.


Is this enforced in JDBC 2.0 also? I could not get documentation abt this for JDBC 2.0...so i am doubtful.
when i run this code, it works fine sometimes. however, sometimes i get,
java.sql.SQLException: ORA-01475: must reparse cursor to change bind variable datatype
this behavior is random. so i am doubtful abt the behavior of setObject()
Can anybody exaplin this?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rashmi,
JDBC doesn't support setting nulls this way. dbforums has a post on this. Some drivers may support it, but it's not universal.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic