Hello everyone.
I develop CDC application for J9 on Pocket PC and have a problem
with serialization of an object containing database connection. I am
using hsqldb CDC version and database enabler for J9.
While serializing I get an exception
java.io.NotSerializableException:
org.hsqldb.jdbc.jdbcConnection
I am confused as I do not use this class excplicite in my project. I am using
org.hsqldb.jdbcDataSource implements javax.sql.DataSource.
More details follow here:
I've got an object of
class DBOntModelImpl extends OntModelImpl implements DBOntModel
The class has a field
transient private Connection dbConnection;
The connection is created as
org.hsqldb.jdbcDataSource dataSource = new jdbcDataSource();
dbConnection = dataSource.getConnection(url);
Knowing that db connection cannot be serialized I did as it is written in the Sun's tutorial at
http://java.sun.com/developer/technicalArticles/Programming/serialization/
namely I set connection as transient, I implemented writeObject and readObject methods and tried to serialize DBOntModelImpl. What I get is:
java.io.NotSerializableException: org.hsqldb.jdbc.jdbcConnection
at
java.io.ObjectOutputStream.checkSerializable(Unknown Source)
at
java.io.ObjectOutputStream.writeNewObject(Unknown Source)
at
java.io.ObjectOutputStream.writeObjectInternal(Unknown Source)
at
java.io.ObjectOutputStream.writeObject(Unknown Source)
at
java.io.ObjectOutputStream.writeObject(Unknown Source)
at
java.io.ObjectOutputStream.writeFieldValues(Unknown Source)
etc.
The code for serializing method is following:
private void writeObject(ObjectOutputStream out) throws IOException
{
this.closeDBConnection();
out.defaultWriteObject();
}
How should I serialize my model then if this does not work??
I have sources of hsqldb-cdc but have no sources for jdbc. I have search the internet but found no similar problem/solution.
Thanks for any clues and ask for details if you need.