If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Serialize DB2Connection

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-23-04, 05:20
cesar cesar is offline
Registered User
 
Join Date: Feb 2003
Posts: 13
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
Reply With Quote
  #2 (permalink)  
Old 01-23-04, 10:11
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Re: Serialize DB2Connection

Quote:
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...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On