aspose file tools*
The moose likes Java in General and the fly likes Store Java object in MySQL Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Store Java object in MySQL Database" Watch "Store Java object in MySQL Database" New topic
Author

Store Java object in MySQL Database

Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
I want to store and retrive Java object in MySQL database.

How can I do that?

Is there any samlpe code?

Reg,
Chetan


My blood is tested +ve for Java.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You need to read about JDBC.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
and object serialisation.


42
Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
Originally posted by Chetan Parekh:
I want to store and retrive Java object in MySQL database.

How can I do that?

Is there any samlpe code?

Reg,
Chetan


Hello Chetan,
This can be done in multiple ways but i can tell you one approach for the same.You can use JDO i.e. Java Data Objects API and call its methods to store and retrive java objects as it is in any database, be it MYSQL.I have done this using JDO .I used Castor JDO for the same.I hope its fine by you.You can visit site of Castor JDO and see more details there.

Alternatively you can use CMP i.e. Container manager persistence featired offered by EJB.

These days hibernate is another OR mapping tool which you can for object persistence.

Saurabh


Success is not doing extraordinary things but doing ordinary things extraordinarily well.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Store Java object in MySQL Database