This section of code doesn't make sense.
Blob blob = rs.getBlob("Image");
int b;
InputStream bis = rs.getBinaryStream("Image");
FileOutputStream f = new FileOutputStream("Image.jpg");
while ((b = bis.read()) >= 0) {
f.write(b);
}
f.close();
bis.close();
icon = new ImageIcon(blob.getBytes(1L, (int) blob.length()));
You basically read the BLOB from result set to a file and then try and read it again to construct your image. It's possible that you've exhausted the stream.
Why not just read the image?
icon = new ImageIcon("Image.jpg");
Better yet, why not take advantage of the ImageIO
API and read the stream directly, for-going the need to write out a temp file?
BufferedImage image = ImageIO.read(bis);
icon = image == null ? null : new ImageIcon(image);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…