File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rashmi Tambe
Ranch Hand
Posts: 418
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic