try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/EMP", "root", "");
PreparedStatement ps = con.prepareStatement("insert into imgtable values(?,?)");
ps.setString(234, "tester");
FileInputStream fin = new FileInputStream("d:\\resume.pdf");
ps.setBinaryStream(2, fin, fin.available());
int i = ps.executeUpdate();
System.out.println(i + " Your details successfully uploaded");
con.close();
} catch (Exception e) {
e.printStackTrace();
}
Using this code i have inserted pdf file into database it's working fine, please help for further process. how to download pdf file form database. using blob data type.
insert into imgtable values(?,?)isn't a good idea (hint: without column names all hell breaks loose should one day the layout of your table change).