Hi Kevin,

I think that Kristian and Bernt have given you the workarounds for this issue. It is true that Java ADTs were supported in earlier versions of Cloudscape. However, those ADTs were declared in a non-standard way. ADT support was disabled before the code was open-sourced as Derby--Derby attempts to follow the SQL Standard as closely as possible.

The good news is that ADT support was only lightly disabled at the parser level. Re-enabling this support with SQL Standard DDL should be straightforward. This effort is tracked by DERBY-651. For more context and for more advice about serializing objects into Derby, please see the following email thread: http://www.nabble.com/Storing-Java-Objects-in-a-table-tf454110.html#a1239466.

Hope this helps,
-Rick

kab wrote:
Hi,

I tried to directly insert a Java object from typ mottrow.MItem to the table ITEMS in my embedded Derby DB. But I got the following error:

java.sql.SQLException: An attempt was made to get a data value of type 'BLOB' from a data value of type ' mottrow.MItem'

In the query I used, I had defined the row ITEM to the typ BLOB, because with the typ JAVA_OBJECT I got an error. In the derby documentation I have read that the a JAVA_OBJECT is stored as BLOB in the DB, so I defined it directly as BLOB.

SQL query used to create table:

String query = "create table APP.ITEMS (" +
"ID INT NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1)," +
                    "ITEM BLOB," +
                    "LEVEL INT NOT NULL," +
                    "OWNER VARCHAR(30)," +
                    "LASTACCESS DATE," +
                    "FORMERLEVEL INTEGER NOT NULL )";

Statement to insert my JAVA_OBJECT:

PreparedStatement stmt = con.prepareStatement("insert into APP.ITEMS (ITEM) VALUES (?)");
            stmt.setObject(1,item);
            stmt.addBatch ( );

Does somebody knows a solution for this problem?


Sincerely

Kevin


Reply via email to