Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

BUG? - Underlying input stream returned zero bytes

10 views
Skip to first unread message

Yang

unread,
Feb 12, 2004, 10:50:24 PM2/12/04
to
Hi,
I've encountered a problem when I'm trying to read data from a empty text
field in sql server 2000.
I created a table with only 2 fields in my database, the fields are listed
below:
Name Type
---------------------
id int
description Text

I've inserted a row into this table, and set the field 'description' to
empty string, when I'm trying to read this row inserted just now from the
table using the ms jdbc driver, it throwed a Exception reported " Underlying
input stream returned zero bytes".

Does any one has any idea about this?
Is this a bug of ms jdbc driver sp1 & sp2?

thanks.

The environment:
===================
OS: Windows 2000
Database: SQL Server 2000 (Simplified Chinese, sp3a)
JDK: jdk1.4
Driver: Microsoft SQL Server 2000 JDBC driver sp1 & sp2

Test Code:
===================
String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url =
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test";
String user = "sa";
String pwd = "";

String sql = "select id, description from TABLE1";

Class.forName(driver);
Connection conn = DriverManager.getConnection(url, user, pwd);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);

while (rs.next()) {
System.out.println("id: " + rs.getString(1));
System.out.println("desc: " + rs.getString(2));

System.out.println();
}


Error reports:
=====================
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Underlying
input stream returned zero bytes
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseData.getString(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.getString(Unknown Source)
at forfeit.test.main(test.java:23)
Exception in thread "main"


Joe Weinstein

unread,
Feb 12, 2004, 11:56:43 PM2/12/04
to Yang
Hi. I wasn't able to duplicate the problem. I used this code:
Statement s = c.createStatement();
s.executeUpdate("create table #foo(bar text)");
s.executeUpdate("insert #foo values('')");

ResultSet r = s.executeQuery("select * from #foo");
while (r.next() ) System.out.println("We got '" + r.getString(1) + "'" );

I got:
We got ''

Then I ran:
Statement s = c.createStatement();
s.executeUpdate("create table #foo(bar text null)");
s.executeUpdate("insert #foo values(null)");

ResultSet r = s.executeQuery("select * from #foo");
while (r.next() ) System.out.println("We got '" + r.getString(1) + "'" );

and got:
We got 'null'

Yang

unread,
Feb 13, 2004, 2:53:50 AM2/13/04
to
Thanks, Joe
I've tested the code in my machine, the same error was produced.
I suppose this would only occur in simplified chinese version of SQL Server
2000.

This is the code:
stmt.executeUpdate("create table #foo(bar text)");
stmt.executeUpdate("insert #foo values('')");

ResultSet rs = stmt.executeQuery("select * from #foo");
while (rs.next() ) {
System.out.println("We got '" + rs.getString(1) + "'");
}

The error:


java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Underlying
input stream returned zero bytes
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseData.getString(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.getString(Unknown Source)

at test.test_b(test.java:28)
at test.main(test.java:9)
Exception in thread "main"

"Joe Weinstein" <joeN...@bea.com> wrote in message
news:402C590...@bea.com...

Joe Weinstein

unread,
Feb 13, 2004, 11:39:24 AM2/13/04
to Yang
Yang wrote:

> Thanks, Joe
> I've tested the code in my machine, the same error was produced.
> I suppose this would only occur in simplified chinese version of SQL Server
> 2000.

It seems there is a diffference in the DBMS perhaps. It definitely is something
MS should fix, and it may be a driver/codeset issue to.
Joe

lucas lee

unread,
Feb 19, 2004, 8:58:18 PM2/19/04
to
i'm meet the same problem.but in my own machine,it can read the empty
text value.but in my server machine 2000server,it doestnt work.

i think may be jdbc driver problem,need install latest version.i doesnt
sure,i'm just trying.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

lrt china

unread,
Feb 29, 2004, 11:39:28 PM2/29/04
to
use jdk1.4.0,not jdk1.4.2.

feng xianwen

unread,
Mar 28, 2004, 6:43:54 AM3/28/04
to

I got the problem after I install JBuilderX.

No problem after I uninstall it.

0 new messages