Jython Data Extraction problem

S

Steve Williams

The data is an 8-byte 2s complement binary integer stored in a MSSQL
2005 CHAR column. (COBOL did that, not me). I'm using zxJDBC to read
the data and Jython to process.
I could extract the integer if it wasn't returned in the resultset as
unicode. Things like ord(char) and struct.unpack('>B',char) to get at
the bits don't seem to work. struct.unpack('>g',string) is not available.
I've tried fooling with charset in the url and the connect statement and
tried encode, but I have no experience here.
Is there anyway to get Jython/zxJDBC to stop converting the string to
unicode?
Any advice is welcome.
 
D

Diez B. Roggisch

Steve said:
The data is an 8-byte 2s complement binary integer stored in a MSSQL
2005 CHAR column. (COBOL did that, not me). I'm using zxJDBC to read
the data and Jython to process.
I could extract the integer if it wasn't returned in the resultset as
unicode. Things like ord(char) and struct.unpack('>B',char) to get at
the bits don't seem to work. struct.unpack('>g',string) is not available.
I've tried fooling with charset in the url and the connect statement and
tried encode, but I have no experience here.
Is there anyway to get Jython/zxJDBC to stop converting the string to
unicode?
Any advice is welcome.

It's a JDBC-thing in the end, see if you find a solution there. Apart from
that, I don't see the problem really - why can't you just create a
byte-string by using the .encode-method? Sure, you need to know which
encoding was actually used when reading the bytes from the DB. But you
should be able to figure that out, there aren't too much candidates -
basically the usual suspects of cp1250, latin1 and the like.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top