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(); }