JDBC Type 4 Driver 2.0 Programmer's Reference (SQL/MX 2.x)

If the translationVerification property’s value is FALSE and the driver cannot translate all or part of an SQL
statement, the translation is unspecified. In most cases, the characters that are untranslatable are encoded as ISO88591
single-byte question marks (‘?’ or 0x3F). No exception or warning is thrown.
If the translationVerification property’s value is TRUE and the driver cannot translate all or part of an SQL
statement, the driver throws an SQLException with the following text:
Translation of parameter to {0} failed. Cause: {1}
where {0} is replaced with the target character set and {1} is replaced with the cause of the translation failure.
For more information, see the translationVerification Property.
Trimming Padding for Fixed-Length Character Columns
Sometimes retrieved values are longer than inserted values for fixed-length character columns that use the KANJI character set
or KSC5601 character set in SQL/MP tables. This subsection describes:
How to reinsert a row that has fixed-length character items.
How padding causes the discrepancy in length.
Under most circumstances (for example, when the default Kanji=SJIS property key-value is set), the padding characters can
be inserted and selected from the database without error.
This is an advanced topic on character-set manipulation on SQL/MP tables.
How to Reinsert a Row that Has Fixed-Length Character Items
Note: The length of a retrieved string might not be correct if the associated column is double-byte and fixed length in
SQL/MP tables (for example KANJI and KSC5601). The number of padding characters might be more than
expected.
To avoid this length problem, ensure that the program trims any trailing white spaces before reinserting such a row before
calling the setString() method.
How the Padding Character Causes the Discrepancy in Length
SQL/MP tables containing fixed-length CHAR columns use an ASCII space character (0x20) as a padding character.
Double-byte character columns (KANJI and KSC5601) use two ASCII space characters (0x2020) as a padding character.
UCS2 uses a single UCS2 space (0x0020) as a padding character.
The 0x2020 character is not a legal character in the Kanji character set, but 0x2020 does represent two legal characters (two
spaces) in the SJIS character set. Under most circumstances the padding characters can be inserted and selected from the
database without error (for example, when the default Kanji=SJIS property key-value is set).
For example, the pseudo code for an insertion into a table that has a column defined as CHAR(6) character set
KANJI, has the following behavior:
byte b1 = new byte[4];
b1[0] = 0x83; \___ Katakana letter A
b1[1] = 0x41; /
b1[2] = 0x83; \___ Katakana letter small i
b1[3] = 0x42; /
String k1 = new String(b1, “SJIS”);
Internally, the JVM stores k1 as UCS2 in 4 octets (bytes). The UCS2 encoding would be:
0x30 0xA2 0x30 0xA3
An SQL insert statement is prepared:
pStmt = conn.PrearedStatement(“insert into t1 values (?)”);