Since you used preparedstatement.setBlob(1, InputStream);
to store the image, I have to assume that you stored the physical image file/format and not just the pixel data.
You need to read back this image format and convert to a supported image format for Swing/Java.
Start by getting a Blob
reference to the database field...
Blob blob = rs.getBlob(1);
Once you have a Blob
, you can use it's binary InputStream
and read the data...
BufferedImage image = null;
try (InputStream is = blob.getBinaryStream()) {
image = ImageIO.read(is);
} catch (IOException exp) {
exp.printStackTrace();
}
Now, you can make it an ImageIcon
using new ImageIcon(image)
and put this within your table model...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…