File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes storing objects in a database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "storing objects in a database" Watch "storing objects in a database" New topic
Author

storing objects in a database

Chris Patton
Greenhorn

Joined: Jun 12, 2000
Posts: 7
I'm relatively new to databases, but I think I've mastered the basic concepts and I was wondering how I would store a java object in a database. As far as I understand, I would just have to serialize it and store it int the database as a blob, but I don't exactly know how i would do this code-wise. I would be eternally grateful if someone could help me out.
Thanks!
- Chris
Milind Kulkarni
Ranch Hand

Joined: Jun 01, 2000
Posts: 146
Hi Chris,
Here is how I would do it:
Blob binobj = rs.getBlob("BINOBJ");
PreparedStatement pstmt = con.prepareStatement( "UPDATE MYTABLE SET BINARYOBJ = ?");
pstmt.setBlob(1, binobj);
pstmt.executeUpdate();
Hope this helps!
Regards,
Milind

[This message has been edited by Milind Kulkarni (edited August 19, 2000).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: storing objects in a database
 
Similar Threads
inserting images into an oracle database
Flat file
encrypt password
How to save values in a database in JSTL?
how to store an image into the DataBase using oracle database