Alef Arendsen wrote:
can't you make any object that you cannot make serializable just TRANSIENT so it won't cause any problems??? alef


You can do this, *if* you have control over the source of the classes in question, and *if* the class will still operate correctly after the object is reloaded, and the transient instance variable has a null value instead of pointing at something real.  I suspect neither of these is likely to be the case for a JDBC driver that you are using.

For example, most JDBC drivers have a buried reference to a java.net.Socket inside their Connection implementations, which is required to perform TCP/IP reads and writes to the database server.  If you mark this variable transient, it will be initialized to null when the object is deserialized and reloaded, so you'll start getting NullPointerException errors -- since the rest of the driver assumes that the socket was initialized at open() time and will not be erased until close().
 

Craig McClanahan
 

Reply via email to