The internationalization features of the Microsoft SQL Server 2005 JDBC Driver include the following:
-
Support for a fully localized experience in the same languages as SQL Server.
-
Support for the Java 1.4 level language conversions for locale sensitive SQL Server data.
-
Support for international languages, regardless of operating system.
Handling of Character Data
Character data in Java is handled as Unicode by default; the Java String object represents Unicode character data. In the JDBC driver, the only exception to this rule is the ASCII stream getter and setter methods, which are special cases because they use byte streams with the implicit assumption of single well-known code pages (ASCII).
In addition, the JDBC driver provides the sendStringParametersAsUnicode connection string property. This property can be used to specify that prepared parameters for character data are sent as ASCII instead of Unicode.
For more information about the sendStringParametersAsUnicode connection string property, see Setting the Connection Properties.
Driver Incoming Conversions
Unicode text data coming from the server does not have to be converted. It is passed directly as Unicode. Non-Unicode data coming from the server is converted from the code page for the data, at the database or column level, to Unicode. The JDBC driver uses the Java Virtual Machine (JVM) conversion routines to perform these conversions. These conversions are performed on all typed String and Character stream getter methods.
If the JVM does not have the proper code page support for the data from the database, the JDBC driver throws a "XXX codepage not supported by the Java environment" exception.
Driver Outgoing Conversions
Character data going from the driver to the server begins as Unicode. Unicode is passed to the server, where the proper conversions are performed if the destination column is not a Unicode typed column (nchar, nvarchar, ntext). In that case, the Unicode text is passed from the JDBC driver setter and updater methods for Strings and Character streams.
Formatting Issues
For date, time, and currencies, all formatting with localized data is performed at the Java language level using the Locale object; and the various formatting methods for Date, Calendar, and Number data types. In the rare case where the JDBC driver must pass along locale sensitive data in a localized format, the proper formatter is used with the default JVM locale.
Non-Unicode Parameters
As a performance enhancement, String parameters can be passed to SQL Server in non-Unicode form by setting the sendStringParametersAsUnicode connection string property. The default setting for sendStringParametersAsUnicode is "true," which means that String parameters are sent as Unicode. If sendStringParametersAsUnicode is set to "false," all String parameters on that connection are sent to the server with the database default collation.