Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在java中显示从数据库到jlabel的blob(图像)_Java - Fatal编程技术网

如何在java中显示从数据库到jlabel的blob(图像)

如何在java中显示从数据库到jlabel的blob(图像),java,Java,我读了很多文章和教程,但仍然没有找到解决方案。我也读了一些关于stackoverflow的帖子,但仍然没有找到解决方案。我请求帮助解决我的问题的一切。早些时候谢谢你。对不起,我的英语乱七八糟 try { int baris = tabelpelanggan.getSelectedRow(); stt = K.PrepareStatement(); rs = stt.executeQuery("select image from pelanggan

我读了很多文章和教程,但仍然没有找到解决方案。我也读了一些关于stackoverflow的帖子,但仍然没有找到解决方案。我请求帮助解决我的问题的一切。早些时候谢谢你。对不起,我的英语乱七八糟

try {
        int baris = tabelpelanggan.getSelectedRow();
        stt = K.PrepareStatement();
        rs = stt.executeQuery("select image from pelanggan where idpelanggan='"
                + tabelpelanggan.getValueAt(baris, 0).toString() + "'");
        byte[] imagee = null;
        while (rs.next()) {
            Blob blob = rs.getBlob("image");

            imagee = blob.getBytes(1, (int) blob.length());
        }

        Image i = Toolkit.getDefaultToolkit().createImage(imagee);
        ImageIcon ii = new ImageIcon(i);
        Image iii = ii.getImage();
        Image newicon = iii.getScaledInstance(labelImage.getWidth(), labelImage.getHeight(), Image.SCALE_SMOOTH);
        ImageIcon icon = new ImageIcon(newicon);
        labelImage.setIcon(icon);

    } catch (SQLException ex) {
        System.out.println(ex.getMessage());
    }

你是说?我试过你的建议,但还是不起作用。没有错误,但在jlabel上什么都没有出现问题,我至少有两个示例,一个是完全可运行的,可以工作的,我甚至不知道您正在使用的数据库或图像如何存储在数据库中