dcsimg

How can I insert images into a Mysql database?

Kasi Mono

This code snippet shows the basics:

File file = new File(fPICTURE);
FileInputStream fis = new FileInputStream(file);
PreparedStatement ps = 
   ConrsIn.prepareStatement("insert into dbPICTURE values (?,?)");

// ***use as many ??? as you need to insert in the exact order*** 
ps.setString(1,file.getName());
ps.setBinaryStream(2,fis,(int)file.length());
ps.executeUpdate();
ps.close();
fis.close();