i want to store the user uploaded image in database using Hibernate. But i am not sure how to do it.. Here is my code
JSP:
<form action="Image" method="post" enctype="multipart/form-data"> <br><br>
<table>
<tr>
<td>UserName: </td>
<td width='10px'></td>
<td><input type="text" name="unname"/></td>
</tr>
<tr>
<td>Upload: </td>
<td width='10px'></td>
<td><input type="file" name="filecover" value="Upload"/></td>
</tr>
<tr>
<td><input type="submit" value="Submit" name="usubmit"></td>
</tr>
</table>
</form>
DAO:
public void savePhoto1(String uname, Blob photo1)
{
Session session = NewHibernateUtil.getSessionFactory().openSession();
Transaction trans =null;
Newsfeed nf = new Newsfeed(); // Pojo Class
try
{
trans=session.beginTransaction();
nf.setUsername(uname);
nf.setPhoto1(photo1);
trans.commit();
}
catch (Exception e)
{
}
}
In Servlet,
Part filePart = request.getPart("filecover");
After this i am not sure how to add this using DAO savephoto1 method.. can anyone help me to proceed.. i need to store image in mySQL blob field and not the path..