Conversão de byte[] para blob [RESOLVIDO]

Saudações Caros…

Segue o trecho abaixo… na linha “5” setBlob estou convertendo de forma errada… OBs: LSEDOC é do tipo byte[] e quero converter para blob!

try {
            stmt = conn.prepareStatement("UPDATE LSE SET LSEDOC =?"
                    + " WHERE PESSOAID='" + vo.getPessoaid() + "'"
                    + " AND SOLID ='" + vo.getSolid() + "'");
            stmt.setBlob(1,(Blob) new ByteArrayInputStream(vo.getLsedoc()));
            stmt.execute();
            conn.commit();
        } catch (SQLException ex) {
            Logger.getLogger(GridControlLSE.class.getName()).log(Level.SEVERE, null, ex);
        }

Ao depurar retorna a seguinte informação:


stmt.setBlob(1, (Blob) new ByteArrayInputStream(vo.getLsedoc())) = >Não se pode converter uma instância de “class java.io.ByteArrayInputStream (no class loader)” para uma instância de “interface java.sql.Blob (no class loader)”<

Solução…

alterar setBlob para setBytes

  1. try {
  2.         stmt = conn.prepareStatement("UPDATE LSE SET LSEDOC =?"  
    
  3.                 + " WHERE PESSOAID='" + vo.getPessoaid() + "'"  
    
  4.                 + " AND SOLID ='" + vo.getSolid() + "'");  
    

5. stmt.setBytes(1, vo.getLsedoc());
6. stmt.execute();
7. conn.commit();
8. } catch (SQLException ex) {
9. Logger.getLogger(GridControlLSE.class.getName()).log(Level.SEVERE, null, ex);
10. }