hi,
i am using MS-SQL server and bita version of the
JDBC driver for that. in my database table i have a field with type "uniqueidentifier" which is 16 byte number with "-" in between. its in format of,
4-2-2-2-6 bytes. (this field has been used to generate unique id for each record i have).
now here comes the problem. when i try to get that field using resultset.getString(1) i get the data correctly but in different byte order.
the interesting thing is the last 8 bytes are in correct order but first 8 are not in order. the byte order is changed for first 8 bytes. so first 4 bytes if i put in reverse order gives me the correct 4 bytes (that corresponds to the first 4 bytes of the database field entry). similar thing for next 2-2 bytes.
e.g. if first 8 bytes are,
A1B2C3D4-AEBC-DF2A in the database field entry then i would get,
D4C3B2A1-BCAE-2ADF when i try resultset.getString(1)...
the rest of the bytes are in correct order.
so last 8 bytes were,
C582-E3FF4562A7DD
then i get,
C582-E3FF4562A7DD as last 8 bytes (so they are in correct order)...
this problem i guess is due to the byte order problem (little endian/big endian). what i guess is, MS-SQL server stores the first 8 bytes in little endian and last 8 bytes in big endian format. so when my
java program gets data by using getString() or getBytes() on resultset i get first 8 bytes in reverse order as i explained. this is due to the fact that java enterprets in big endian format!
well i can get around the problem just by adjusting the first 8 bytes but is my reasoning correct about the problem? and if there is another way out?
well i yet need to check the metadata col type for this field (i didnt get time and it occurred to my mind after i was out the office...)...
can anybody throw some light on this if you have encountered similar problem?
regards
maulin.