Discussion:
JAVA_OBJECT Problem with byte[64] and byte[0] array
Klaus, Gerd
2006-02-09 14:08:51 UTC
Permalink
Hi All,

Table definition:

CREATE TABLE IF NOT EXISTS xyz (
identifier INTEGER NOT NULL PRIMARY KEY,
parameter JAVA_OBJECT);

Data in Table:
identifier | parameter
-----------+-------------
1 | boolean[64]
2 | byte[64]
3 | int[64]
4 | int[64]
5 | boolean[64]
6 | int[1]
7 | byte[0][0]
8 | byte[0]
9 | int[0]
10 | int[0]
11 | boolean[0]
12 | boolean[1]
13 | boolean[1]

INSERT and UPDATE works fine with all 13 identifier.

READING data with "SELECT identifier,parameter FROM xyz ORDER BY
identifier ASC;" also. But if I try to read the 'parameter' column with
"ResultSet.getObject(2)" after a the SELECT, an exception at
'identifier' 2 and 8 is thrown:

Exception at identifier 2:
Exception in thread "main" java.lang.Error: De-serialization error:
invalid stream header
at
com.mckoi.database.global.ObjectTranslator.deserialize(ObjectTranslator.
java:107)
at
com.mckoi.database.jdbc.MResultSet.getRawColumn(MResultSet.java:592)
at com.mckoi.database.jdbc.MResultSet.getObject(MResultSet.java:1105)
at
mmr.DB.statements.DbAlarmBrdSer.getParameters(DbAlarmBrdSer.java:97)
at mmr.MIDAS.loadAlarmBrdDat(MIDAS.java:1052)
at mmr.MIDAS.main(MIDAS.java:692)

Exception at identifier 8:
Exception in thread "main" java.lang.Error: De-serialization error: null
at
com.mckoi.database.global.ObjectTranslator.deserialize(ObjectTranslator.
java:107)
at
com.mckoi.database.jdbc.MResultSet.getRawColumn(MResultSet.java:592)
at com.mckoi.database.jdbc.MResultSet.getObject(MResultSet.java:1105)
at
mmr.DB.statements.DbAlarmBrdSer.getParameters(DbAlarmBrdSer.java:102)
at mmr.MIDAS.loadAlarmBrdDat(MIDAS.java:1052)
at mmr.MIDAS.main(MIDAS.java:692)

Any ideas why the exceptions are thrown?


Best regards,

Gerd
------------------------------------------------------------------------------------------------
This message is for the designated recipient only and may
contain privileged, proprietary, or otherwise private information.
If you have received it in error, please notify the sender
immediately and delete the original. Any unauthorized use of
this email is prohibited.
------------------------------------------------------------------------------------------------
[mf2]


---------------------------------------------------------------
Mckoi SQL Database mailing list http://www.mckoi.com/database/
To unsubscribe, send a message to mckoidb-***@mckoi.com
Klaus, Gerd
2006-02-09 14:35:20 UTC
Permalink
Sorry, I forgot the Mckoi Version. I am using Mckoi 1.0.3.

Best Regards,
Gerd
-----Original Message-----
Of Klaus, Gerd
Sent: Thursday, February 09, 2006 3:09 PM
Subject: JAVA_OBJECT Problem with byte[64] and byte[0] array
Hi All,
CREATE TABLE IF NOT EXISTS xyz (
identifier INTEGER NOT NULL PRIMARY KEY,
parameter JAVA_OBJECT);
identifier | parameter
-----------+-------------
1 | boolean[64]
2 | byte[64]
3 | int[64]
4 | int[64]
5 | boolean[64]
6 | int[1]
7 | byte[0][0]
8 | byte[0]
9 | int[0]
10 | int[0]
11 | boolean[0]
12 | boolean[1]
13 | boolean[1]
INSERT and UPDATE works fine with all 13 identifier.
READING data with "SELECT identifier,parameter FROM xyz ORDER BY
identifier ASC;" also. But if I try to read the 'parameter'
column with
"ResultSet.getObject(2)" after a the SELECT, an exception at
invalid stream header
at
com.mckoi.database.global.ObjectTranslator.deserialize(ObjectT
ranslator.
java:107)
at
com.mckoi.database.jdbc.MResultSet.getRawColumn(MResultSet.java:592)
at
com.mckoi.database.jdbc.MResultSet.getObject(MResultSet.java:1105)
at
mmr.DB.statements.DbAlarmBrdSer.getParameters(DbAlarmBrdSer.java:97)
at mmr.MIDAS.loadAlarmBrdDat(MIDAS.java:1052)
at mmr.MIDAS.main(MIDAS.java:692)
Exception in thread "main" java.lang.Error: De-serialization
error: null
at
com.mckoi.database.global.ObjectTranslator.deserialize(ObjectT
ranslator.
java:107)
at
com.mckoi.database.jdbc.MResultSet.getRawColumn(MResultSet.java:592)
at
com.mckoi.database.jdbc.MResultSet.getObject(MResultSet.java:1105)
at
mmr.DB.statements.DbAlarmBrdSer.getParameters(DbAlarmBrdSer.java:102)
at mmr.MIDAS.loadAlarmBrdDat(MIDAS.java:1052)
at mmr.MIDAS.main(MIDAS.java:692)
Any ideas why the exceptions are thrown?
Best regards,
Gerd
------------------------------------------------------------------------------------------------
This message is for the designated recipient only and may
contain privileged, proprietary, or otherwise private information.
If you have received it in error, please notify the sender
immediately and delete the original. Any unauthorized use of
this email is prohibited.
------------------------------------------------------------------------------------------------
[mf2]


---------------------------------------------------------------
Mckoi SQL Database mailing list http://www.mckoi.com/database/
To unsubscribe, send a message to mckoidb-***@mckoi.com
Tobias Downer
2006-02-15 00:21:46 UTC
Permalink
Thanks. I wrote a test case for this and was able to reproduce the error.

This is actually a design flaw in the way the Mckoi JDBC driver sends
and receives Java byte[] objects. When serializing a Java object, Mckoi
wraps the serialized data form in a ByteLongObject (which is basically
just a byte[] array). Unfortunately, Mckoi also uses a ByteLongObject
to represent byte[] objects. When using 'getObject', Mckoi
automatically assumes the ByteLongObject is a serialized Java object and
attempts to deserialize it. When it's a byte[] array, this fails.

An easy workaround for you would be to wrap all byte[] objects that you
give to 'setObject' with a custom Serializable class. eg.

class AByteArray implements java.io.Serializable {
byte[] byte_arr;
}

So all byte[] objects read with 'getObject' would become AByteArray
objects instead.

Unfortunately this kind of fix can't be implemented in the JDBC driver
code because getObject has to work for byte[] array data that has been
written to the database in other ways.

Hope this helps and thanks for the bug report,
Toby.
Post by Klaus, Gerd
Sorry, I forgot the Mckoi Version. I am using Mckoi 1.0.3.
Best Regards,
Gerd
-----Original Message-----
Of Klaus, Gerd
Sent: Thursday, February 09, 2006 3:09 PM
Subject: JAVA_OBJECT Problem with byte[64] and byte[0] array
Hi All,
CREATE TABLE IF NOT EXISTS xyz (
identifier INTEGER NOT NULL PRIMARY KEY,
parameter JAVA_OBJECT);
identifier | parameter
-----------+-------------
1 | boolean[64]
2 | byte[64]
3 | int[64]
4 | int[64]
5 | boolean[64]
6 | int[1]
7 | byte[0][0]
8 | byte[0]
9 | int[0]
10 | int[0]
11 | boolean[0]
12 | boolean[1]
13 | boolean[1]
INSERT and UPDATE works fine with all 13 identifier.
READING data with "SELECT identifier,parameter FROM xyz ORDER BY
identifier ASC;" also. But if I try to read the 'parameter'
column with
"ResultSet.getObject(2)" after a the SELECT, an exception at
invalid stream header
at
com.mckoi.database.global.ObjectTranslator.deserialize(ObjectT
ranslator.
java:107)
at
com.mckoi.database.jdbc.MResultSet.getRawColumn(MResultSet.java:592)
at
com.mckoi.database.jdbc.MResultSet.getObject(MResultSet.java:1105)
at
mmr.DB.statements.DbAlarmBrdSer.getParameters(DbAlarmBrdSer.java:97)
at mmr.MIDAS.loadAlarmBrdDat(MIDAS.java:1052)
at mmr.MIDAS.main(MIDAS.java:692)
Exception in thread "main" java.lang.Error: De-serialization
error: null
at
com.mckoi.database.global.ObjectTranslator.deserialize(ObjectT
ranslator.
java:107)
at
com.mckoi.database.jdbc.MResultSet.getRawColumn(MResultSet.java:592)
at
com.mckoi.database.jdbc.MResultSet.getObject(MResultSet.java:1105)
at
mmr.DB.statements.DbAlarmBrdSer.getParameters(DbAlarmBrdSer.java:102)
at mmr.MIDAS.loadAlarmBrdDat(MIDAS.java:1052)
at mmr.MIDAS.main(MIDAS.java:692)
Any ideas why the exceptions are thrown?
Best regards,
Gerd
------------------------------------------------------------------------------------------------
This message is for the designated recipient only and may
contain privileged, proprietary, or otherwise private information.
If you have received it in error, please notify the sender
immediately and delete the original. Any unauthorized use of
this email is prohibited.
------------------------------------------------------------------------------------------------
[mf2]
---------------------------------------------------------------
Mckoi SQL Database mailing list http://www.mckoi.com/database/
---------------------------------------------------------------
Mckoi SQL Database mailing list http://www.mckoi.com/database/
To unsubscribe, send a message to mckoidb-***@mckoi.com

Loading...