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();
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact