Microsoft KB Archive/894559

= FIX: You receive an &quot;Underlying input stream returned zero bytes&quot; error message when you use the SQL Server 2000 Driver for JDBC to retrieve the value from an empty text column =

Article ID: 894559

Article Last Modified on 10/7/2005

-

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:

http://support.microsoft.com/contactus/?ws=support

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 &quot;Applies to&quot; section.



Steps to reproduce the behavior
  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   Compile and then run the following Java code: import java.sql.*; public class Test {   public static void main(String[] args) throws Exception {       String driver = &quot;com.microsoft.jdbc.sqlserver.SQLServerDriver&quot;; String url = &quot;jdbc:microsoft:sqlserver://:1433;DatabaseName=pubs&quot;; String user = &quot;&quot;; String pwd = &quot;&quot;;

String sql = &quot;SELECT * FROM repro&quot;;

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(&quot;id: &quot; + rs.getString(1)); System.out.println(&quot;logo: &quot; + rs.getString(2)); System.out.println; }       }        finally {           rs.close; }   } }  Note In this code, replace ,  , and   with the name of your computer that is running SQL Server, your user ID, and your password. 

<div class="references_section">