Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2003
    Posts
    13

    Unanswered: Serialize DB2Connection

    Hello,

    I am trying to serialize a class which connects to a DB2 server. I obtain the following error: java.io.NotSerializableException: COM.ibm.db2.jdbc.app.DB2Connection

    Does anybody have any idea?

    Thanks,

    Cesar

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: Serialize DB2Connection

    Originally posted by cesar
    Hello,

    I am trying to serialize a class which connects to a DB2 server. I obtain the following error: java.io.NotSerializableException: COM.ibm.db2.jdbc.app.DB2Connection

    Does anybody have any idea?

    Thanks,

    Cesar
    That's because you can't serialize a database connection - it is meaningles.

    You could use writeObject() and readObject methods to do the following:
    1) create a wrapper around the Connection class
    2) in the wrapper class implement writeObject() that would write connection information (url, userid, password) instead of the Connection itself
    3) also implement readObject() that reads the connection information from the deserialization stream and establishes a new Connection using those data

    Look at javadoc for the Serializable interface for more information.

    By the way, this has nothing to do with DB2...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •