JDBC Type 4 Driver Programmer's Reference for SQL/MX Release 3.2 (H06.25+, J06.14+)

The java.sql.ResultSet class contains the methods getString() and
getCharacterStream(). These methods return a String parameter and Reader parameter,
respectively.
Retrieving a Column
When you retrieve a column as a String (for example, call the getString() or
getCharacterStream methods), the Type 4 driver uses the character-set mapping property key
to instantiate a String object (where that key corresponds to the character set of the column).
For example: the following SQL create table statement creates a table that has an ISO88591
column.
create table t1 (c1 char(20) character set ISO88591)
The JDBC program uses the following java command to set the ISO88591 property and issues
the getString() method.
java Dt4sqlmx.ISO88591=SJIS test1.java
// The following method invocation returns a String object, which
// was created using the SJIS Java canonical name as the charset
// parameter to the String constructor.
String s1 = rs.getString(1); // get column 1 as a String
Setting a Parameter
When you set a parameter by using a String (for example, call the setString() method), the
Type 4 driver uses the key’s value when generating the internal representation of the String (where
that key corresponds to the character set of the column). The character-set parameter to the String
getBytes method is the Java Canonical name that corresponds to the column’s character set.
For example, the following SQL create table statement creates a table that has an ISO88591
column:
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).
30 Accessing SQL Databases with SQL/MX