【发布时间】:2012-05-25 07:25:20
【问题描述】:
我有一张名为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");
我知道,这行不通。请帮我重新编码。
【问题讨论】:
-
任何人都可以帮助我......
标签: java mysql sql database sqlexception