2

I am receiving following bit value for a column which have 1 value in MYSQL Database.

Query: (select IFNULL(FIELDA, 0) from ADRESS where ID=1234) as FIELDAS
Output: [B@74d3dc29
Expected: 1 or 0

I also access boolean at many places in code but never returned this object.

How to handle it in Java? Which datatype it will pick as i am unable to cast it to Java.SQL.BLOB?

Note: My Code is also using Hivernate framework, if anyone know hibernate class to manage it please tell

fatherazrael
  • 5,511
  • 16
  • 71
  • 155
  • 1
    It's a ``byte[]``. A ``blob`` type is just a wrapper for binary data, in this case the ``[B`` at the start of the output tells you its a byte array. – f1sh Aug 10 '16 at 13:10
  • But when i used it -> byte[] b = (byte[]) tuple[17]; and tried to print it -> System.out.println(""+ b.toString()); It shows same object and does not show value expected – fatherazrael Aug 10 '16 at 13:21
  • Possible duplicate of [What's the simplest way to print a Java array?](http://stackoverflow.com/questions/409784/whats-the-simplest-way-to-print-a-java-array) – JonK Aug 10 '16 at 13:30
  • @JonK: It is not yet clear whether this is due to byte array and i am not getting expected results. So Don't gave it possible duplicate tag :) – fatherazrael Aug 10 '16 at 15:18
  • In SQL Query i removed IFNULL(FIELDA, 0) and casted it to Unsigned to make it suitable for Java Code!! – fatherazrael Aug 11 '16 at 08:47
  • @fatherazrael ``b.toString()`` is not going to work if ``b`` is a ``byte[]``. – f1sh Aug 11 '16 at 08:54

0 Answers0