JDBC Type 4 Driver Programmer's Reference for SQL/MX Release 3.2.1

create table t1 (c1 char(20) character set ISO88591);
> java DISO88591=SJIS test1.java
The following method invocation sets column one of stmt to the String abcd” where abcd” is
encoded as SJIS. The charset parameter to the String getBytes method is SJIS.
stmt.setString(1, abcd);
Controlling an Exception
You can use the translationVerification property to explicitly define the behavior of the
driver if the driver cannot translate all or part of an SQL parameter. The value portion of the property
can be TRUE or FALSE. (The default value is FALSE).
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 (page 50).
Trimming Padding for Fixed-Length Character Columns
Retrieved values might be 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:
“Reinserting a Row that Has Fixed-Length Character Items (page 30)
“Discrepancy in Length Caused by Padding Character Causes (page 30)
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.
Reinserting 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.
Discrepancy in Length Caused by Padding Character Causes
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:
30 Accessing SQL Databases with SQL/MX