1
All right, all right? I have stored a BLOB file and am looking to do recovery of it, is a JPG.
Below is the Resultset of the same:
byte[] bin = null; // (2)
ResultSet rs;
try {
rs = produtoControle.escolha(buscar.getText());
while(rs.next()){
lblNumId.setText(rs.getString("codigo"));
tfNome.setText(rs.getString("nome_produto"));
cbCategoria.setSelectedItem(String.valueOf(rs.getString("categoria")));
tfQuantidade.setText(rs.getString("quantidade"));
tfPreco.setText(rs.getString("preco"));
tfFabDist.setText(rs.getString("fabricante"));
tfResponsavel.setText(rs.getString("responsavel"));
tftTelefone.setText(rs.getString("telefone"));
tfEmail.setText(rs.getString("email"));
taInfo.setText(rs.getString("informacoes"));
bin = rs.getBytes("imagem");
}
ByteArrayInputStream bis = new ByteArrayInputStream(bin);
Iterator <?> readers = ImageIO.getImageReadersByFormatName("jpg");// (2)
ImageReader reader = (ImageReader) readers.next();
Object source = bis;
ImageInputStream iis;
try {
iis = ImageIO.createImageInputStream(source);
reader.setInput(iis, true);
ImageReadParam param = reader.getDefaultReadParam();
Image imagem = reader.read(0, param);
foto.setIcon(new ImageIcon(imagem.getScaledInstance(foto.getWidth(), foto.getHeight(), imagem.SCALE_DEFAULT)));
} catch (IOException ex) {
Logger.getLogger(InterfaceProduto.class.getName()).log(Level.SEVERE, null, ex);
}
if("".equals(lblNumId.getText())){
fechaConexao();
return;
}
} catch (SQLException ex) {
Logger.getLogger(InterfaceProduto.class.getName()).log(Level.SEVERE, null, ex);
}
ValidaCampos("novo");
btSalvar.setText("Alterar");
btExcluir.setEnabled(true);
fechaConexao();
}
And the following error occurs when stamping it on JLABEL:
debug: Nov 26, 2017 10:41:44 pm view.Interfaceproduct searchKeyPressed GRAVE: null javax.imageio.Iioexception: Not a JPEG file: Starts with 0xac 0xed at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImageHeader(Native Method) at com.sun.imageio.plugins.jpeg.JPEGImageReader.readNativeHeader(Jpegimagereader.java:620) at com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(Jpegimagereader.java:347) at com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(Jpegimagereader.java:492) at com.sun.imageio.plugins.jpeg.JPEGImageReader.readHeader(Jpegimagereader.java:613) at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(Jpegimagereader.java:1070) at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(Jpegimagereader.java:1050) at view.InterfaceProduct.buscarKeyPressed(Interfaceproduct.java:542) at view.InterfaceProduct.access$600(Interfaceproduct.java:63) at view.Interfaceproduct$8.keyPressed(Interfaceproduct.java:301) at java.awt.Component.processKeyEvent(Component.java:6491) at javax.swing.Jcomponent.processKeyEvent(Jcomponent.java:2832) at java.awt.Component.processEvent(Component.java:6310) at java.awt.Container.processEvent(Container.java:2236) at java.awt.Component.dispatchEventImpl(Component.java:4889) at java.awt.Container.dispatchEventImpl(Container.java:2294) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.Keyboardfocusmanager.redispatchEvent(Keyboardfocusmanager.java:1954) at java.awt.Defaultkeyboardfocusmanager.dispatchKeyEvent(Defaultkeyboardfocusmanager.java:806) at java.awt.Defaultkeyboardfocusmanager.preDispatchKeyEvent(Defaultkeyboardfocusmanager.java:1074) at java.awt.Defaultkeyboardfocusmanager.typeAheadAssertions(Defaultkeyboardfocusmanager.java:945) at java.awt.Defaultkeyboardfocusmanager.dispatchEvent(Defaultkeyboardfocusmanager.java:771) at java.awt.Component.dispatchEventImpl(Component.java:4760) at java.awt.Container.dispatchEventImpl(Container.java:2294) at java.awt.Window.dispatchEventImpl(Window.java:2746) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.Eventqueue.dispatchEventImpl(Eventqueue.java:758) at java.awt.Eventqueue.access$500(Eventqueue.java:97) at java.awt.Eventqueue$3.run(Eventqueue.java:709) at java.awt.Eventqueue$3.run(Eventqueue.java:703) at java.security.Accesscontroller.doPrivileged(Native Method) at java.security.Protectiondomain$Javasecurityaccessimpl.doIntersectionPrivilege(Protectiondomain.java:80) at java.security.Protectiondomain$Javasecurityaccessimpl.doIntersectionPrivilege(Protectiondomain.java:90) at java.awt.Eventqueue$4.run(Eventqueue.java:731) at java.awt.Eventqueue$4.run(Eventqueue.java:729) at java.security.Accesscontroller.doPrivileged(Native Method) at java.security.Protectiondomain$Javasecurityaccessimpl.doIntersectionPrivilege(Protectiondomain.java:80) at java.awt.Eventqueue.dispatchEvent(Eventqueue.java:728) at java.awt.Eventdispatchthread.pumpOneEventForFilters(Eventdispatchthread.java:201) at java.awt.Eventdispatchthread.pumpEventsForFilter(Eventdispatchthread.java:116) at java.awt.Eventdispatchthread.pumpEventsForHierarchy(Eventdispatchthread.java:105) at java.awt.Eventdispatchthread.pumpEvents(Eventdispatchthread.java:101) at java.awt.Eventdispatchthread.pumpEvents(Eventdispatchthread.java:93) at java.awt.Eventdispatchthread.run(Eventdispatchthread.java:82)
SUCCESSFULLY BUILT (total time: 18 seconds)
I wonder what I might have missed...I’ve done exit tests with Println and back characters, which means there is saved image in the bank!