0

i have this code that when i click the jtable, the picture from my database will display in my interface. but every time i click malformedUrlexception pop up. can please somebody help me?

    private void recordTBLMouseClicked (java.awt.event.MouseEvent evt){
        String click = (recordTBL.getModel().getValueAt(row, 0).toString());
        try {
            clsConnect c = new clsConnect();
            Connection conn = c.makeConnection();
            String sql = "Select image from employeetbl where idnum = '" + click + "'";
            pst = conn.prepareStatement(sql);
            rs = pst.executeQuery();
            while (rs.next()) {

                URL imagedate = new URL("image");

                BufferedImage bufferedimage1 = ImageIO.read(imagedate);
                finalimage = new ImageIcon(resize(bufferedimage1, imageL.getWidth(), imageL.getHeight()));
                imageL.setIcon(finalimage);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e);
        }
    }
puj
  • 770
  • 5
  • 9
ken abaki
  • 97
  • 1
  • 9

1 Answers1

0

This line is your problem:

URL imagedate = new URL("image");

"image" is not a URL. You need to pass a valid URL to the URL constructor. e.g. "http://www.stackoverflow.com"

Dermot Blair
  • 1,600
  • 10
  • 10
  • so what would be the posible code so i can get the image from database and the bufferedImage can read this. – ken abaki Mar 15 '15 at 00:18
  • The top answer of this question might help you: http://stackoverflow.com/questions/2150265/retrieve-an-image-stored-as-blob-on-a-mysql-db – Dermot Blair Mar 15 '15 at 01:41