Discussions

General J2EE: inserting binary data(images,music) into MS Access using jsp

  1. i have been tring to insert an image into ms access but it has not been working for me using the "setBinaryStream()", please can anyone help witha code for inserting binary files into a MS Access DB using JSP?
  2. Which driver are you using?
  3. File file=new File("c:/testpic.jpg"); FileInputStream in=new FileInputStream(file); PreparedStatement ps=connection.prepareStatement("insert into image_table (IMAGE) values(?);"); ps.setBinaryStream(2,in,(int)file.length()); ps.execute(); ps.close(); And make sure the Type is OLE for the field which contains the Image data.
  4. one correction , the index 2 should be 1 ps.setBinaryStream(1,in,(int)file.length());