• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

storing objects in a database

 
Chris Patton
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic