我使用的代码:
private void okActionPerformed(java.awt.event.ActionEvent evt)
{
try {
String Update = name.getText();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection = DriverManager.getConnection("jdbc:odbc:NewPData");
PreparedStatement psmnt = connection.prepareStatement("SELECT Image FROM Table1 where Name='" + Update + "'");
ResultSet rs = psmnt.executeQuery();
Blob blob = rs.getBlob("Image");
int b;
InputStream bis = rs.getBinaryStream("Image");
FileOutputStream f = new FileOutputStream("Image.jpg");
while ((b = bis.read()) >= 0) {
f.write(b);
}
f.close();
bis.close();
icon = new ImageIcon(blob.getBytes(1L, (int) blob.length()));
lblImage.setIcon(icon);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
异常表现:
java.lang.UnsupportedOperationException
我已经先存储在MS Access的图像,现在我想表明它的标签上。 请帮忙。