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"
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'
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...
> 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
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!
No problem after I uninstall it.