title: Byte array to blob in java
body: <p>I have a database in mysql. In this I have a table which is storing image in blob format.
  From my Java program I want to insert a new image into the table.
  But When I tried to convert a <code>byte[]</code> to blob using </p>
  
  <pre><code>java.sql.Blob blob=null;
  blob.setBytes(1, myByte );
  </code></pre>
  
  <p>I am getting null pointer exception.</p>
  
  <p>Again tried by converting:</p>
  
  <pre><code> Blob blob = Hibernate.createBlob(bytes);
  </code></pre>
  
  <p>But here also got exception wrong format.</p>