This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to store a Java Object directly in to a database table

 
Ankur Saxena
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Every body,

I wanna Store a Java Object directly in to a database table. For doing so I want to know that which data type should I take for a database table column and how it is possible to store a java object in to a Database table. If any body has idea, plz reply .

Thks in Advance

Regards

Ankur Saxena
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you serialize an object, that essentially turns it into a byte[] (or data written to an OutputStream), and then you can use the SQL type BLOB. How do you insert a BLOB? Google for that. If you are using Hibernate (judging from your crosspost) this is especially easy to do. Your POJO could make methods that are backed by the same data:
 
Ankur Saxena
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thks Jeff for ur kind suggestion,

I did the same ,but before ur reply and it is working fine.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to provide an alternate view: Don't. We very rarely put java objects into the DB (I can think of two instances) you're far better of using an ORM toll and mapping the object to a table.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic