
sir, I want to do update image into database

updateimage.jsp:
<%@page import="java.sql.*,java.io.*"%>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
File imgfile = new File("C:/pic.jpg");
FileInputStream fin = new FileInputStream(imgfile);
PreparedStatement pre = con.prepareStatement("update image set images=? where id=?");
pre.setBinaryStream(1,fin,(int)imgfile.length());
pre.setInt(2,1);
pre.executeUpdate();
out.println("updated Successfully!");
pre.close();
}
catch(Exception ex){
out.println("error :"+ex);
}
%>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.