This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes save jpeg in mysql using struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "save jpeg in mysql using struts" Watch "save jpeg in mysql using struts" New topic
Author

save jpeg in mysql using struts

ramandeep singh
Greenhorn

Joined: Jan 16, 2007
Posts: 13
i am making struts application in which i need to put .jpeg image,resume.doc or resume.rtf file in to Mysql database
how can i do tht ,
i tried setBlob(byte[])
and
try {

pst.setBinaryStream(18,form.getpic().getInputStream());
} catch (FileNotFoundException ex) {
errors.add("sqlError",new ActionMessage("errors.resume.emptyfile"));
} catch (IOException ex) {
errors.add("sqlError",new ActionMessage("errors.resume.emptyfile"));
}
but they are causing exceptions ,can i also save the .doc file in same format and how to download them
[ January 18, 2007: Message edited by: ramandeep singh ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This link has a good example of reading from and writing to a BLOB.


Merrill
Consultant, Sima Solutions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: save jpeg in mysql using struts