Answer the question
In order to leave comments, you need to log in
What is the correct way to load an image into a BLOB field?
Greetings dear people working to change the world. I have a question for you again. Stuck on loading image in BLOB field, in oracle sql table, how to do it right? At the moment the situation is as follows:
Created a BLOB field in an oracle sql table to write images from the site into it.
The HTML code that is sent to the servlet is:
th Your photo /th
form action = "images" method= "post" enctype="multipart/form-data"
input type= "file" name="images" /
input type= "text" name="user_id"/
input type="submit" value ="Upload"
/form
tr/
JAVA code on the servlet that receives the request and sends it to the server:
try{
String sql= "update tbl_customer set images1='"+request.getParameter("images").toString()+"' where user_id='"+request.getParameter("user_id").toString()+"' ";
OraclePreparedStatement pst=(OraclePreparedStatement)conn.prepareStatement(sql);
OracleResultSet rs = (OracleResultSet) pst.executeQuery();
pst.execute();
response.sendRedirect(response.encodeRedirectURL("PersonalSave.jsp"));
if(rs.next()){
HttpSession session = request.getSession();
session.setAttribute("user_id", rs.getString("user_id"));}
}catch(Exception e){
out.println(e);
e.printStackTrace();}}}} Resulting in an
error:
java.lang.NullPointerException
Thanks in advance for your feedback.
Sincerely, M.M.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question