我有一个图像名为P100.jpg
。我正在调整它,它被转换成ZP100.png
。我通过插入查询将它存储到数据库MySQL中。从数据库检索图像并在标签中显示
File imageFile = new File("F:\\POSTERS\\Roses\\ZP100.png");
FileInputStream fis = new FileInputStream(imageFile);
String insertImage = "insert into image values(?,?)";
prestmt = con.prepareStatement(insertImage);
prestmt.setInt(1,4);
prestmt.setBinaryStream(2, fis, fis.available());
result = prestmt.executeUpdate();
现在我想检索该图像并通过将其分配给标签来显示在窗体上。
String selectImage = "select img from image";
prestmt = con.prepareStatement(selectImage);
但它给我的异常,因为
java.sql.SQLException: Can not issue executeUpdate() for SELECTs
对于一个标签赋予图像,我有:
image.setText("ZP100.png");
我知道,这是行不通的。请帮我重新编码这个。
任何人都可以请帮我...... – Anjali
检查我的答案 –