I am trying to load an image which is in a MySQL database as blob data format ([B@e96bf
) but I can't load it to a JLabel as shown below. It shows the ByteArrayInputStream
is empty.
byte[] bytesl = null;
ResultSet rs = DB.DB.search("select image from imageio where id = '2'");
while (rs.next()) {
bytesl = rs.getBytes(1);
}
BufferedImage imag = ImageIO.read(new ByteArrayInputStream(bytesl));
Image img = imag;
img = img.getScaledInstance(jLabel1.getWidth(), jLabel1.getHeight(),
Image.SCALE_SMOOTH);
jLabel2.setIcon(new ImageIcon(img));