I have been trying to upload image
to database. So I made a browse
button to go through directories and get the image. Suppose if no image is selected, a default image
will be uploaded to the database. The image is stored in a folder named 'resources'
under source folder.In the image, helper is the folder containting .java files and below is the resources
folder I am uploading the image as
FileInputStream
and the code is
File pic=new File(imgloc);
FileInputStream fis=new FileInputStream(pic);
If the image is not selected to upload a default image my code is
File pic=new File(this.getClass().getResource("/resources/profile1.png").getFile());
FileInputStream fis=new FileInputStream(pic);
And my query to database is
ps.setBinaryStream(1,fis ,(int) pic.length()); //While substituing for '?' in query
After build to jar it produce FileNotFoundException
when trying to add default image. May be the question is asked several times I didn't find solution in that. I want read the image as file..Thanks in advance.