You’ll need to be able to serialize your object into a byte stream and then recreate your object from a byte stream.
Then, just store that byte stream in your db.
EDIT:
Read this article to learn about serialization in Java. It caters to the subject in a much better way than I would be able to by just giving some code snippets.