how to show image from ms access to jpanel in java netbeans

Posted by Shiv on Stack Overflow See other posts from Stack Overflow or by Shiv
Published on 2012-12-12T05:00:41Z Indexed on 2012/12/12 5:03 UTC
Read the original article Hit count: 191

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about java

Related posts about netbeans