0
Good evening, here’s the deal: I have a Jlabel = jlImage, where an image is loaded as shown by the btnCaminhoImagemActionPerformed method.
But I want to use the save button to insert the image in the database, but I don’t know how to get the value of this jLabel which parameter should I pass in Preparedstatement? NOTE: The image is like longBlob in my base. Thanks for your cooperation.
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();
}
Try the following:http://stackoverflow.com/a/19310279/5524514
– user28595
Blz... Thank you...
– Carlos Leandro Ferreira de Alm