Using jConnect to Pass Unicode Data

In Adaptive Server version 12.5 and later, database clients can take advantage of the unichar and univarchar datatypes

The two datatypes allow for the efficient storage and retrieval of Unicode data, allowing users to designate database table columns to store Unicode data, regardless of the default character set of the server.

Quoting from the Unicode Standard, version 2.0:

The Unicode Standard is a fixed-width, uniform encoding scheme for encoding characters and text. The repertoire of this international character code for information processing includes characters for the major scripts of the world, as well as technical symbols in common. The Unicode character encoding treats alphabetic characters, ideographic characters, and symbols identically, which means they can be used in any mixture and with equal facility. The Unicode Standard is modeled on the ASCII character set, but uses a 16-bit encoding to support full multilingual text.
Note: In Adaptive Server version 12.5 through 12.5.0.3, the server was required to use a default character set of utf-8 to use the Unicode datatypes. However, in Adaptive Server 12.5.1 and later, database users can use unichar and univarchar without having to consider the default character set of the server.
You can use the unichar and univarchar datatypes anywhere that you can use char and varchar character datatypes, without having to make syntax changes.
  • unichar – use n to specify the number of Unicode characters (the amount of storage allocated is 2 bytes per character).
  • univarchar – usen to specify the maximum length in characters for the variable-length datatypes.
When the server accepts unichar and univarchar data, jConnect behaves as follows:
  • For all character data that a client sends to the server—for example, using PreparedStatement.setString (int column, String value)—jConnect determines if the string can be converted to the default character set of the server.

  • If jConnect determines that the characters cannot be converted to the character set of the server (for example, some characters cannot be represented), it sends the data to the server encoded as unichar/univarchar data.

For example, if a client attempts to send a Unicode Japanese character to an Adaptive Server 12.5.1 that has iso_1 as the default character set, jConnect detects that the Japanese character cannot be converted to an iso_1 character. jConnect then sends the string as Unicode data.

There is a performance penalty when a client sends unichar/univarchar data to a server, because jConnect must perform character-to-byte conversion twice for all strings and characters that do not map directly to the default character set of the server.

If you are using a jConnect version that is earlier than 6.05 and you want to use the unichar and univarchar datatypes, you must:

  1. Set the JCONNECT_VERSION = 6 or later.
  2. Set the DISABLE_UNICHAR_SENDING connection property to false.

    For more information on support for unichar and univarchar datatypes, see Adaptive Server Enterprise Manuals.

Related tasks
Setting Connection Properties
Related reference
JCONNECT_VERSION Connection Property