In Netbeans I took a Desktop Pane and inside that pane I took Label.Inside the Label I want to show image which is already stored in Database(sqlite manager) by clicking a button.This is the code I've tried,
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
try
{
String sql = "Select Image from EmployeeInfo where EmployeeId=1";
pst=conn.prepareStatement(sql);
pst.executeQuery();
if(rs.next())
{
byte[] imagedata = rs.getBytes("Image");
format = new ImageIcon(imagedata);
lbl_image.setIcon(format);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
And I also declared a global variable in my code,
private ImageIcon format = null;
But it is not showing the picture when I click the button.It is not giving any error or exception.Program run successfully but not showing image inside the Label.I can't figure out what I did wrong and what to do to solve it.I am a beginner in java.Anyone help me please.
You forgot...
rs = pst.executeQuery();