Results 1 to 2 of 2
- 01-18-2009, 07:39 AM #1
Member
- Join Date
- Jan 2009
- Posts
- 1
- Rep Power
- 0
File upload into database using Hibernate
Hello all,
Can anyone please help..
I am designing a webapplication in java. I have set up forms and sucessfully upload data into mysql database. I now want to upload a file.
i have created my class..
and my jsp.pageJava Code:import java.io.Serializable; import java.sql.Blob; public class User implements Serializable { private Long userId; private Blob upfile; public Long getUserId() { return userId; } public void setUserId(Long userId) { this.userId = userId; } public Blob getUpfile() { return upfile; } public void setUpfile(Blob upfile) { this.upfile = upfile; } }
i have also done the user.hbm.xml asJava Code:<form name="upform" enctype="multipart/form-data" action="servlet/building?action=UpLoadFile" method="POST"> Name:<input type="file"/><br> <input type="submit" value="Upload"/> </form>
The problem i have is i dont know what my action class would be like..Java Code:<class name="com.attainware.maven2example.model.User" table="users"> <id name="userId" column="USERID"> <generator class="native" /> </id> <property name="upfile" type="blob" column="USER_FILEBIN"/> </class>
for normal upload i ise somethin like...
the question is how do i do this action for a file. so it stores it in the database.Java Code:public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String id = (String) request.getParameter("id"); user = new User(); user.setId(id); Session session = HibernateUtil.getSessionFactory().getCurrentSession(); Transaction tx = session.beginTransaction(); session.save(user); tx.commit();
Thank you for your help in advance..
- 02-28-2010, 03:11 AM #2
Member
- Join Date
- Aug 2008
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Upload excel data to access database
By ravikumar.achi in forum New To JavaReplies: 20Last Post: 01-19-2012, 11:30 AM -
Hibernate with multiple database
By Marty in forum JDBCReplies: 3Last Post: 12-23-2008, 12:57 PM -
how to upload a file?
By tommy in forum JavaServer Pages (JSP) and JSTLReplies: 4Last Post: 06-30-2008, 02:50 PM -
file upload
By sundarjothi in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 06-27-2008, 11:52 AM -
File Upload
By ShoeNinja in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 11-09-2007, 10:09 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks