我想在数据库的JFrame中添加图像。但这不是重复的。我使用以下代码,这是从数据库中检索图像的正确方法吗?什么是解决方案???
Blob blob = rs.getBlob("image");
int blobLength = (int) blob.length();
byte[] bytes = blob.getBytes(1, blobLength);
//blob.free();
BufferedImage image = ImageIO.read(new ByteArrayInputStream(bytes));
ImageIcon icon = new ImageIcon(bytes); // you can read straight from byte array
l16 = new JLabel(icon);
l16.setBounds(100, 100, 100, 50);
add(l16);