Originally posted by Huzefa Zohaib: Can I write the object to Database I want to write the object in database can I do it by converting it to set of bytes or strings or otherwise.
Hi, You may do so using setObject() method in PreparedStatement, provided u'r object has an equivalent SQL Type mapping(Please refer the java doc for more details). Otherwise, you have to convert your object into byte and then set the same using setBytes() method. In the code snippet given below, I have assumed that the object to be stored in database implements serializable/externalizable interface.
This will insert the object into database. While retrieving the object, you have to do the reverse procedure; take the byte; then create a ByteArrayInputStream; ObjectInputStream on top of ByteArrayInputStream and then call readObject(). regards Jacob