我有一张名为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");
我知道,它不能工作。请帮我重新编码。