FIX: You receive an "Underlying input stream returned zero bytes" error message when you use the SQL Server 2000 Driver for JDBC to retrieve the value from an empty text column (894559)



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 retrieve the value from an empty text column, you may experience the following error message:
[Microsoft][SQLServer 2000 Driver for JDBC]Underlying input stream returned zero bytes

CAUSE

This problem can occur if the text column is defined by using certain collations. For example, the text column may be defined by using the SQL_Latin1_General_CP1250_CI_AS or Chinese_PRC_CI_AS SQL collations. You do not receive this error message with all Java Virtual Machines (JVMs).

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 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.
  Date         Time  Version   Size     File name
  -----------------------------------------------------
  27-Aug-2004  5:46  2.2.0042  286,953  Msbase.jar
  27-Aug-2004  5:46  2.2.0042   67,115  Mssqlserver.jar
  27-Aug-2004  5:46  2.2.0042   59,072  Msutil.jar

STATUS

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

MORE INFORMATION

Steps to reproduce the behavior

  1. Create a sample table by using the following script:
    USE pubs
    GO
    CREATE TABLE repro (id INT IDENTITY(1, 1) PRIMARY KEY, logo TEXT COLLATE Chinese_PRC_CI_AS NULL)
    GO
    INSERT INTO repro (logo) VALUES ('')
    GO
  2. Compile and then run the following Java code:
    import java.sql.*;
    public class Test
    {
    	public static void main(String[] args) throws Exception
    	{
    		String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    		String url = "jdbc:microsoft:sqlserver://<Server>:1433;DatabaseName=pubs";
    		String user = "<UserID>";
    		String pwd = "<Password>";
    
    		String sql = "SELECT * FROM repro";
    
    		Class.forName(driver);
    		Connection conn = DriverManager.getConnection(url, user, pwd);
    		Statement stmt = conn.createStatement();
    		ResultSet rs = stmt.executeQuery(sql);
    
    		try
    		{
    			while (rs.next())
    			{
    				System.out.println("id: " + rs.getString(1));
    				System.out.println("logo: " + rs.getString(2));
    				System.out.println();
    			}
    		}
    		finally
    		{
    			rs.close();
    		}
    	}
    }
    Note In this code, replace <Server>, <UserID>, and <Password> with the name of your computer that is running SQL Server, your user ID, and your password.

REFERENCES

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

313100 How to get started with Microsoft JDBC

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


Modification Type:MinorLast Reviewed:10/7/2005
Keywords:kbBug kbJDBC kbDatabase kberrmsg kbQFE kbfix KB894559 kbAudDeveloper