
Hi How to upload images in db. using jsf. For jsf photo uploading .. I used this one code for upload image..
But this code haven't option to upload any images . i want to store image in db for that second thing have done it..It also check the image extension......
public void save(Registrationbean bean) { try {
PreparedStatement ps =null;
FileInputStream fis = null;
String uname =bean.getUname();
Blob img2 =bean.getImge();
File img = new File("img2");
String qry = "insert into application_table(name,image)values('"+ uname+"','"+img2+"')";
fis = new FileInputStream(img);
ps.setBinaryStream(2, fis, (int)img.length());
ps = con.prepareStatement(qry);
System.out.println("save registration::::" + ps);
stmt.executeUpdate(qry);
} catch (Exception ex) {
ex.printStackTrace();
}
}
Any one plz Guide me.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.