Table Structure - Column X(Binary (15),null)
Value in Column X - 000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000
i.e 15x8=120 bits
SQL query
Select X from tablename;
Java Code part for retrieving value: barray is byte[] and bits is new BitSet().
barray = resultset.getBytes("X");
if(barray != null) {
for (int i = 0; i < barray.length * 8; i++) {
if ((barray[barray.length-i/8-1]&(1<<(i%8))) > 0) {
bits.set(i);
}
}
}
Problem: The 2nd if statement is returning false value(not sure y?) thus the bits object is not getting populated. Please suggest a solution.