File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Oracle boolean data type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Oracle boolean data type" Watch "Oracle boolean data type" New topic

Oracle boolean data type

Nair Anoop
Ranch Hand

Joined: May 09, 2001
Posts: 68
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
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 567
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.

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.
I agree. Here's the link:
subject: Oracle boolean data type
jQuery in Action, 3rd edition