Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes Oracle boolean data type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Oracle boolean data type" Watch "Oracle boolean data type" New topic
Author

Oracle boolean data type

Nair Anoop
Ranch Hand

Joined: May 09, 2001
Posts: 68
Hi,
I am currrently using :
boolean status = rsInfo.getBoolean("status");
to access a boolean (Yes / No) field in an Access DB.
If I need to port this to Oracle, will I need to make the field as Number(1) and use
int status = rsInfo.getInt("status");
and thus change all my Java code
Thanks,
Anoop
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
Generally in Oracle people use a Char(1) field and store 'T' and 'F' or 'Y' and 'N'. However with resultSet.getBoolean() that will throw an exception.
With java I just tried it out since I'm interested, if you use a number column, resultSet.getBoolean() works if you use 0 = false and null = false. Everything else is true.
Adam


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
 
jQuery in Action, 2nd edition
 
subject: Oracle boolean data type