Writing a complex object to DB2

I am trying to write a complex Java object to a DB2 (v5) LONG VARHCAR AS BIT DATA column.  This object consists of various other objects, which contain other objects, etc.

Doing this to a file is a one-line ordeal.  I can't seem to find anything similar to serialize this to the database.

Any ideas of how I can just take this object and persist it (maybe using PreparedStatement.setObject()) with a minimum of changes to the object?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

serialize object in memory (in byte array) and save the bye array in the database (as blob)

something like

ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);

byte[] serialezedObj = bos.toByteArray() ;

// now save the byte[] to the database

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mfeldmeiAuthor Commented:
Replacing oos.write(yourObject) with oos.writeObject(yourObject) works beautiful!  Thanks heyhey_!
Thanks for the points :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.