I am trying to show a image from mysql in a jtextpane but doesn't work,the problem appears when I try to turn the inputstream into BufferedImage, could you help me?
private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 508, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);
    JTextPane textPane = new JTextPane();
    textPane.setEditable(false);
    textPane.setBounds(55, 40, 370, 192);
    frame.getContentPane().add(textPane);
    try{
        Statement a = (Statement) con.createStatement();
        ResultSet b = a.executeQuery("Select imagen from chat");
        InputStream i = null;
        ImageIcon ii = null;
        if (b.next()) {
            i = b.getBinaryStream("imagen");
            BufferedImage bi = ImageIO.read(i);
            ii = new ImageIcon(bi);
            textPane.insertIcon(ii);
        }
    } catch ( SQLException | IOException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
    } 
}
the console said...
java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at imagen.initialize(imagen.java:75)
I can't find the solution
 
     
    