• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Oracle Null Value

 
rasit fidanov
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem with Null value passed in a column of oracle table.

How can i get and set a NUMBER column with a NULL value.

if i try to get a record having Null value ResultSet's getInt() method returns 0 !?..

And setting a column with Null, how to do it using PreparedStatement and Statement?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rasit,
To set a null, there is a setNull() method on PreparedStatement. To see whether a column is null, get it (like you are doing) and then call isNull() on the result set.
 
rasit fidanov
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again,

Thank you for your answer.However, there is not isNull() method in Resultset interface?
Or i could not see?i checked it carefully from javadoc, but i could not see it.
Which version of java did you tell me?java 5.0?

We still have to use 1.4 for J2EE as you know.

Ummm i checked 5.0 too from sun's site's javadoc.I could not see the method.

Its too important for me.Because i try to check with getString method of ResultSet whether a value is null or not .It returns null for an Number column.

I dont like this way..

There must be a better way to check it.
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne meant wasNull(), in ResultSet class.
Since you call it AFTER calling a getXXX() method
 
rasit fidanov
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ahaaaa.

Thats just what i want...

This is much more tender way to find out whether it was null or not.

thank you.

How lucky i am, i met javarunch by chance.I am learning here more and more day by day.

Thank you all ,i will have more questions in future too.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sonny Gill:
Jeanne meant wasNull(), in ResultSet class.
Since you call it AFTER calling a getXXX() method

Thanks Sonny!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic