Olha, eu vou passar tudo o que vc tem que fazer nessa resposta, ok? Está testado e funcionando, se você não conseguir, infelizmente não tem como eu te ajudar, vc tem que começar a aprender do zero.
Pra testar é só criar duas classe e copiar esses códigos abaixo
SALVAR IMAGEM
public class InserirImagem {
//var global
ConectaBanco conecta = new ConectaBanco();
public void inserirBanco(String nome, byte[] img) {
conecta.conexao();
try {
PreparedStatement pst = conecta.conn.prepareStatement("INSERT INTO morador (nome, imagem) VALUES (?,?)");
pst.setString(1, nome);
pst.setBytes(2, img);
pst.executeUpdate();
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
conecta.desconecta();
}
}
private byte[] converterImagem(File file) throws FileNotFoundException {
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
try {
for (int readNum; (readNum = fis.read(buf)) != -1;) {
bos.write(buf, 0, readNum);
}
} catch (IOException ex) {
ex.printStackTrace();
}
byte[] bytes = bos.toByteArray();
return bytes;
}
private void enviarDados() {
try {
byte[] byteImage = converterImagem(new File("C:\\Imperium\\logonew (1).png"));
inserirBanco("Abner Rodrigues", byteImage);
} catch (FileNotFoundException ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
new InserirImagem().enviarDados();
}
}
MOSTRAR IMAGEM
public class MostrarImagem extends javax.swing.JFrame {
public MostrarImagem() {
initComponents();
procurar_todos();
}
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
camponome = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
campoimagem = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jPanel1.setBackground(new java.awt.Color(255, 255, 255));
jPanel1.setLayout(null);
jPanel1.add(camponome);
camponome.setBounds(40, 320, 460, 20);
jLabel1.setText("Nome");
jPanel1.add(jLabel1);
jLabel1.setBounds(40, 300, 27, 14);
jPanel1.add(campoimagem);
campoimagem.setBounds(140, 20, 270, 260);
getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 540, 360));
pack();
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Windows".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MostrarImagem.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MostrarImagem().setVisible(true);
}
});
}
private javax.swing.JLabel campoimagem;
private javax.swing.JTextField camponome;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
// End of variables declaration
ConectaBanco conecta = new ConectaBanco();
Image image = null;
public void procurar_todos() {
conecta.conexao();
try {
conecta.executaSQL("SELECT * FROM morador ORDER BY id");
conecta.rs.last();
String nome = conecta.rs.getString("nome");
getImage(conecta.rs.getBytes("imagem"));
ImageIcon i = new ImageIcon(new ImageIcon("output.jpg").getImage().getScaledInstance(campoimagem.getWidth(), campoimagem.getHeight(), Image.SCALE_SMOOTH));
camponome.setText(nome);
campoimagem.setIcon(i);
} catch (SQLException e) {
e.printStackTrace();
} finally {
conecta.desconecta();
}
}
public byte[] getImage(byte[] img) {
try {
ByteArrayInputStream bis = new ByteArrayInputStream(img);
BufferedImage bImage2 = ImageIO.read(bis);
ImageIO.write(bImage2, "jpg", new File("output.jpg"));
} catch (IOException ex) {
Logger.getLogger(MostrarImagem.class.getName()).log(Level.SEVERE, null, ex);
}
return img;
}
}