how to show image from ms access to jpanel in java netbeans
- by Shiv
I have used this code :
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();
}
}
Exception it show is
java.lang.UnsupportedOperationException
i have stored image first in ms access and now i want to show it on a label plz help