Doubt when saving image in mysql database

0

Good evening, it's as follows: I have a JLabel = jlImage, where an image is loaded as shown in the btnCamageImageActionPerformed method.

But I want to use the save button to insert the image into the database, but I do not know how to get the value of that jLabel which parameter should I pass in the PreparedStatement? NOTE: The image is as longBlob at my base. Thanks in advance for your collaboration.

 private void btnCaminhoImagemActionPerformed(java.awt.event.ActionEvent evt) {                                                 
             JFileChooser fc = new JFileChooser();
             fc.showOpenDialog(this);
             File f = fc.getSelectedFile();
             String path = f.getAbsolutePath();


             ImageIcon imagem = new ImageIcon(f.getAbsolutePath());

             Image imag = imagem.getImage().getScaledInstance(jlImagem.getWidth(), jlImagem.getHeight(), Image.SCALE_DEFAULT);

             jlImagem.setIcon(new ImageIcon(imag));

  }     




private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {                                          

   conexaoProdutos.conexao();

 PreparedStatement pst = conexaoProdutos.conn.prepareStatement("INSERT INTO produto (imagem) VALUES (?)");

        pst.set(1, );//O que usar como parâmetro?
        pst.execute();

    }                                        
    
asked by anonymous 09.05.2016 / 01:13

0 answers