Hi,

Is your object really serializable? Can you serialize it to a file? Are
all it's members serializable or transient?

Another approach if you are having problems would be to serialize it by
hand to a byte[] (using ByteArrayOutputStream) and then store it as a
byte[] (SQL BLOB I guess) on the database.

Rgds,

Dan.

-- 
Danny Yates


-----Original Message-----
From: Milen Dyankov [mailto:[EMAIL PROTECTED] 
Sent: 18 November 2003 16:11
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] TypeConvertionException with Firebird Database



Alexey Loubyansky wrote:
> If defaults do not work for you, you should try different types 
> yourself. Please, let us know your findings. Thanks.
> 

We did some tests and here is what we have found out.
The following works fine:

        Class.forName("org.firebirdsql.jdbc.FBDriver");
        Connection connection =
DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:dbname",
"dbuser", "dbpassword");
         PreparedStatement statement = connection.prepareStatement("INSERT
INTO TEST (blob_field) VALUES (?)");
-->     statement.setObject(1, "simple test");
         statement.executeUpdate();
         statement.close();
         connection.close();

but the following fails with "TypeConvertionException"

        Class.forName("org.firebirdsql.jdbc.FBDriver");
        Connection connection =
DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:dbname",
"dbuser", "dbpassword");
         PreparedStatement statement = connection.prepareStatement("INSERT
INTO TEST (blob_field) VALUES (?)");
-->     statement.setObject(1, new MyObject("test")); // "MyObject"
implements Serializable
         statement.executeUpdate();
         statement.close();
         connection.close();


After reading some documentation and exploring some examples regarding
JayBird (JDBC driver for Firebird)
we are under the impression that setObject() works only with java types
which have their own setters
(such us java.lang.String, java.lang.Integer, etc.).
In the above mentioned examples "setBinaryStream()" was used to set BLOB
fields and there was no example
of setObject().

I suppose the problems lays on JayBird's side!
Just out of curiosity though, does the CMP engine always call setObject() or
it tries to figure out the
field type and use appropriate method?

If someone have ever managed to store serialized object into Firebird,
please share your experience?

Best regards,
Milen Dyankov



-------------------------------------------------------
This SF. Net email is sponsored by: GoToMyPC
GoToMyPC is the fast, easy and secure way to access your computer from
any Web browser or wireless device. Click here to Try it Free!
https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


-------------------------------------------------------
This SF. Net email is sponsored by: GoToMyPC
GoToMyPC is the fast, easy and secure way to access your computer from
any Web browser or wireless device. Click here to Try it Free!
https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to