sql BIT to Java

10.9k Views Asked by At

My sqlserver table has a column designed as a BIT datatype. It has values 1 and 0s

Then in my Java code, I do

result = new ArrayList
result.add( (Boolean)(rs.getBoolean("columnName")));

Then when I read the value from the list - it shows as Long. According to everything I find, it says hat a BIT datatype is supposed to map to boolean.

Why does it come as Long?
What can be done to fix this?

1

There are 1 best solutions below

5
On BEST ANSWER

You can call getBoolean directly and let it take care of all the casting/coverting:

result.add(rs.getBoolean("columnName"));