异常 Underlying input stream returned zero bytes 解决办法
500 Servlet Exception
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 com.microsoft.jdbc.base.BaseResultSet.getString(Unknown Source)
at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:224)
at org.hibernate.type.StringType.get(StringType.java:18)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
这是由于JDBC的BUG导致,通过hibernate 3.0连接sql server 2000时,由于表中有text字段所以抛此导常,解决方法:修改hibernate配置文件,改为JTDS方式连接数据库,如下:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>net.sourceforge.jtds.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:jtds:sqlserver://192.168.2.10:1433;DatabaseName=cnooc_new</value>
</property>
<property name="username">
<value>sa</value>
</property>
<property name="password">
<value>eweb</value>
</property>
</bean>
注意:jtds不支持连接SQL 2005数据库
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 com.microsoft.jdbc.base.BaseResultSet.getString(Unknown Source)
at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:224)
at org.hibernate.type.StringType.get(StringType.java:18)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
<property name="driverClassName">
<value>net.sourceforge.jtds.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:jtds:sqlserver://192.168.2.10:1433;DatabaseName=cnooc_new</value>
</property>
<property name="username">
<value>sa</value>
</property>
<property name="password">
<value>eweb</value>
</property>
</bean>