Insert Picture : Binary « Database « Java Tutorial






FileInputStream fis = null;
      PreparedStatement ps = null;
      try {
         File file = new File(photo);
         fis = new FileInputStream(file);
         ps = conn.prepareStatement("insert into pictable(id, name, pic)values(?,?,?)");
         ps.setString(1, id);
         ps.setString(2, name);
         ps.setBinaryStream(3, fis,(int)file.length());
         ps.executeUpdate();

      }








20.21.Binary
20.21.1.Insert Binary Data into a Database Table Using a Statement?
20.21.2.Get Binary Data from a Database Table?
20.21.3.Insert Picture