0

I use jt400 to get data from database on as400 - db2.

My database use ccsid 37 encoding. I have problem with polish letters only. How can I force jt400 to use proper encoding?

I tried

jdbc:as400://MY_SYSTEM/LIBRARY;translate binary=true AS400Text converer = new AS400Text(stringFromDb.length(), 37); String stringAfterConversion = converter.toObject(stringFromDb.getBytes()); 

but it doesn't work

4
  • Perhaps the answer to this SO-question might help you: http://stackoverflow.com/questions/33560726/how-to-convert-a-string-to-ccsid-37-in-java Commented May 24, 2016 at 9:52
  • It doesn't work System.getProperty("com.ibm.cics.jvmserver.local.ccsid") return null Commented May 24, 2016 at 10:17
  • What happens if you use the charset in getBytes? stringFromDb.geBytes("Cp037") Commented May 24, 2016 at 10:36
  • or maybe select cast(columnname as varchar(255) CCSID 037) from table. Commented May 24, 2016 at 10:41

2 Answers 2

4

CCSID 37 is English and does not contain certain Polish characters. The Polish CCSID is 1153, or 870 (without Euro symbol).

You can see the symbols contained in CCSID 37 (Character set 697) here: ftp://ftp.software.ibm.com/software/globalization/gcoc/attachments/CS00697.pdf

You can see the symbols contained in CCSID 1153 (Character set 1375) here: ftp://ftp.software.ibm.com/software/globalization/gcoc/attachments/CS01375.pdf

If the database field contains CCSID 37 you will not be able to store the characters that are missing CCSID from 1153. Common characters will be converted. You could try changing your database to use UTF-16 or CCSID 1200. That contains all the characters in CCSID 37 and CCSID 1153.

Sign up to request clarification or add additional context in comments.

1 Comment

You're right. I haven't checked CCSID doesn't contain polish characters. Somebody set up wrong encoding and put polish characters to database. That's why I can't read it properly.
2

If things are set up properly, you shouldn't need to do any manual conversion. The DB and JDBC driver handle it for you.

You say your DB is using CCSID 37, which is English as used in the US, Canada, Netherlands, Portugal, Brazil, New Zealand, Australia.

To handle Polish characters, you'd probably need CCSID 870 (per Language identifiers and associated default CCSIDs)

However, CCSID is assigned per column. So everything in that column in that table would need to be in one or the other CCSID.

If you need to store both English & Polish in the same column in the same table, then the best option would be to change the column(s) to Unicode.

Alternatively, you could flag the data as "binary" CCSID 65535, so that the system won't try to convert it. You'd need translate binary=false and your application would be responsible for knowing which records were in English and which were in Polish. So you'd need some additional flag field in the record.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.