-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Hello,
I noticed that the DB2Developerextension doesn't support custom encoding and no JDBC-Parameter exist for encoding.
Problem
Our DB2 subsystems zparm are set up with CCSID 037 (USA) and Tables are usually set up with EBCDIC encoding.
Our 3270 Emulators are set up with CCSID 1141 (German Euro). So when we query a Table we get the correct conversion of Character.
e.g.
Select 'ä'
,SUBSTR(CMCACATEG,17,1)
,HEX(SUBSTR(CMCACATEG,17,1))
from
DB2B.CMTTCATG
where CMCAID = 5
with UR;
Normal Insert using JDBC
SPECIAL CHARACTER CONVERSION FROM JDBC TO MAINFRAME
**Encoded using encode("cp1141").decode("cp037")**
value from select JDBC: äöüÄÖÜ}{[]§&ß
value from select z/OS: {¦}[\]üä¬|@&~
decoded value : {¦}¢\!üäÄÜ@&~
expected Output : {¦}¢\!üäÄÜ@&~
Normal Insert on Mainframe
SPECIAL CHARACTER CONVERSION FROM MAINFRAME TO JDBC
**Encoded using encode("cp037").decode("cp1141")**
value from select JDBC: {¦}¢\!üäÄÜ@&~
value from select z/OS: äöüÄÖÜ}{[]§&ß
decoded value : äöüÄÖÜ}{[]§&ß
expected Output : äöüÄÖÜ}{[]§&ß
**encoded_value = 'äöüÄÖÜ}{[]§&ß'.encode("cp1141").decode("cp037")
sql = f"""INSERT INTO DB2B.TESTTEST (TSTTVALUE, TSTTCOMMENT)
VALUES ('{encoded_value}', 'SPECIAL CHARACTER CONVERSION FROM JDBC TO MAINFRAME WITH ENCODING CP1141 AND CP037')
"""**
SPECIAL CHARACTER CONVERSION FROM JDBC TO MAINFRAME WITH ENCODING CP1141 AND CP037
value from select JDBC: {¦}¢\!üäÄÜ@&~
value from select z/OS: äöüÄÖÜ}{[]§&ß
decoded value : äöüÄÖÜ}{[]§&ß
expected Output : äöüÄÖÜ}{[]§&ß
Solution
If possible, add a "db2forzosdeveloperextension.encoding" setting for encoding using the extensions logic.
It could encode the values to "cp037" (EBCDIC) and decode them using "cp1141" (IBM-1141)
or viseversa for insert using JDBC to mainframe
in java
byte[] ebcdicBytes = ebcdicString.getBytes(Charset.forName("Cp037"));
return new String(ebcdicBytes, Charset.forName("Cp1141"));
in python
decoded_text = records.encode("cp037").decode("cp1141")
# or
decoded_text = tst_value.encode("cp1141").decode("cp037")
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

