2

Is it possible to use the rs.getboolean method to get the value of tinyint(0/1) out of SQL? like this:

while (rs.next()) {
    boolean noUse= rs.getBoolean(1);
}

If this does not work, I suppose you have to do something like this:

while (rs.next()) {
    boolean noUse= rs.getByte(1)==1;
}

Thanks for helping me out.

1 Answers1

4

The option 1 should work fine and I have used the same.

while (rs.next()) {
boolean noUse= rs.getBoolean(1);
}

In mysql, tinyint act as boolean (but save the physical value as 0/1) When you perform the above code,

if field value = 0 then ; noUse=false else if field value= 1 then ; noUse=true