FIX: Some parameter values that are sent in a non-Unicode format may be incorrectly converted when you use the SQL Server 2000 Driver for JDBC (910369)



The information in this article applies to:

  • Microsoft SQL Server 2000 Driver for JDBC

SYMPTOMS

When you use the Microsoft SQL Server 2000 Driver for JDBC to send parameter data in a non-Unicode format, some parameter values may be incorrectly converted.

Note This problem occurs when the following conditions are true:
  • You use data in the range of 0x80 to 0x9F that is encoded by using Latin 1 standard characters.
  • The SendStringParametersAsUnicode connection string property is set to False.

RESOLUTION

A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft SQL Server 2000 Driver for JDBC service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
File nameFile versionFile sizeDateTimePlatform
Msbase.jarNot Applicable287,00708-Jun-200523:20Not Applicable
Mssqlserver.jarNot Applicable67,20308-Jun-200523:20Not Applicable
Msutil.jarNot Applicable56,53708-Jun-200523:20Not Applicable

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

For more information, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates

Code to reproduce the problem

import java.sql.*;

/*Run the following commands in SQL Query Analyzer before you try the code sample.*/ 
/*use Northwind
GO
create table texttable( text varchar(20))
GO */ 

public class Params
{
	static Connection con;

	public static void main(String[] args) throws SQLException
	{
		try
		{
			Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); 

			Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Northwind;SendStringParametersAsUnicode=false;selectmethod=direct","uid","pwd");


			String text = "abcd\u20ac\u201a\u0192\u201e";

			System.out.println("Inserting:");
			for (int i=0; i<text.length(); i++)
			{
				int ivalue = text.charAt(i);
				String output =  Integer.toHexString( (int) ivalue) ;
				System.out.print(output + " ");
			}
			System.out.println();	
			
			PreparedStatement pstmt = null;
			String sqlQuery = "delete from texttable;insert into texttable (text) values (?)";

			pstmt = con.prepareStatement(sqlQuery);
			pstmt.setString(1, text);
			pstmt.execute();

			pstmt.close();
			pstmt=null;

			Statement st = con.createStatement();
			ResultSet rs=st.executeQuery("Select text from texttable");
			System.out.println("Obtained:");
			while (rs.next())
			{
				String s = rs.getString(1);
				for (int i=0; i<s.length(); i++)
				{
					int ivalue = s.charAt(i);
					String output =   Integer.toHexString( (int) ivalue) ;
					System.out.print(output + " ");
				}
				System.out.println();
			}

			con.close();
			con=null;
		}
		catch(Exception e)
		{
			System.out.println(e);
			e.printStackTrace();
		}
	}
}


Output before fix

Inserting:
61 62 63 64 20ac 201a 192 201e
Obtained:
61 62 63 64 ac 1a 3f 1e

Output after fix

Inserting:
61 62 63 64 20ac 201a 192 201e
Obtained:
61 62 63 64 20ac 201a 192 201e

Modification Type:MajorLast Reviewed:2/15/2006
Keywords:kbtshoot kbfix kbbug kbmsccsearch kbpubtypekc KB910369 kbAudITPRO