| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 612 人关注过本帖
标题:『出错』请教sql server连接的两个问题,我实在找不到解决办法
只看楼主 加入收藏
gzdlw
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-3-9
收藏
 问题点数:0 回复次数:0 
『出错』请教sql server连接的两个问题,我实在找不到解决办法
软件环境:
hibernate3.0.5 + spring1.2.6+Tapestry4.0+JDK5.0

我先用JTDS1.0连接数据库
配置文件:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="url" value="jdbc:jtds:sqlserver://localhost:1433/iceroom"/>
<property name="username" value="adong"/>
<property name="password" value="123456"/>
</bean>

<!-- Hibernate SessionFactory for SQL Server -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:com/iceroom/mapping/</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.jdbc.fetch_size">50</prop>
<prop key="hibernate.jdbc.batch_size">100</prop>
</props>
</property>
</bean>
<!-- Hibernate SessionFactory for SQL Server -->
错误提示信息:
org.hibernate.exception.GenericJDBCException:
could not execute query

sql:
select article0_.id as id0_, articlecat1_.id as id1_, userbasic2_.id as id2_, article0_.reply_id as reply2_0_0_, article0_.title as title0_0_, article0_.content as content0_0_, article0_.publish_date as publish5_0_0_, article0_.reply_date as reply6_0_0_, article0_.view_number as view7_0_0_, article0_.top_flag as top8_0_0_, article0_.lock_flag as lock9_0_0_, article0_.pith_flag as pith10_0_0_, article0_.amend_number as amend11_0_0_, article0_.amend_date as amend12_0_0_, article0_.user_id as user13_0_0_, article0_.category_id as category14_0_0_, articlecat1_.category_name as category2_1_1_, articlecat1_.resume as resume1_1_, articlecat1_.head_logo as head4_1_1_, articlecat1_.visualize_loge as visualize5_1_1_, articlecat1_.flag as flag1_1_, userbasic2_.user_name as user2_12_2_, userbasic2_.head_logo as head3_12_2_, userbasic2_.visualize_loge as visualize4_12_2_, userbasic2_.qnumnber as qnumnber12_2_, userbasic2_.website as website12_2_, userbasic2_.profession as profession12_2_, userbasic2_.living_skill1 as living8_12_2_, userbasic2_.resume as resume12_2_, userbasic2_.living_skill2 as living10_12_2_ from article article0_ left outer join article_category articlecat1_ on article0_.category_id=articlecat1_.id left outer join user_basic userbasic2_ on article0_.user_id=userbasic2_.id where article0_.reply_id=0 order by article0_.publish_date desc

SQLState: HY000
errorCode: 0
messages: could not execute query
The amount of data read from the stream is not = length.

throwableCount: 2
throwables: org.hibernate.exception.GenericJDBCException: could not execute query
java.sql.SQLException: The amount of data read from the stream is not = length.


java.sql.SQLException :
The amount of data read from the stream is not = length.
SQLState: HY000
errorCode: 0

我租用了一个服务器空间发布我的程序,本机上我使用SQL server个人版sp3,服务器上使用SQL server服务器版sp4。

本机上调试完全没有问题,如果将hibernate打印的SQL放到服务器的SQL server上运行,也完全没有问题。

但是我的程序在发布之后却报上面的错误。这个问题困扰我一个星期了,如果有解决的朋友,请告知,不胜感激:)。



我试着换用JDBC来进行数据库连接,却发现一个更奇怪的现象。

配置文件:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
<property name="url" value="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=iceroom"/>
<property name="username" value="adong"/>
<property name="password" value="123456"/>
</bean>

<!-- Hibernate SessionFactory for SQL Server -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:com/iceroom/mapping/</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.jdbc.fetch_size">50</prop>
<prop key="hibernate.jdbc.batch_size">100</prop>
</props>
</property>
</bean>
<!-- Hibernate SessionFactory for SQL Server -->

错误信息:
org.hibernate.exception.GenericJDBCException
could not execute query
SQL: select article0_.id as id0_, userbasic1_.id as id1_, article0_.reply_id as reply2_0_0_, article0_.title as title0_0_, article0_.content as content0_0_, article0_.publish_date as publish5_0_0_, article0_.reply_date as reply6_0_0_, article0_.view_number as view7_0_0_, article0_.top_flag as top8_0_0_, article0_.lock_flag as lock9_0_0_, article0_.pith_flag as pith10_0_0_, article0_.amend_number as amend11_0_0_, article0_.amend_date as amend12_0_0_, article0_.user_id as user13_0_0_, article0_.category_id as category14_0_0_, userbasic1_.user_name as user2_12_1_, userbasic1_.head_logo as head3_12_1_, userbasic1_.visualize_loge as visualize4_12_1_, userbasic1_.qnumnber as qnumnber12_1_, userbasic1_.website as website12_1_, userbasic1_.profession as profession12_1_, userbasic1_.living_skill1 as living8_12_1_, userbasic1_.resume as resume12_1_, userbasic1_.living_skill2 as living10_12_1_ from article article0_ left outer join user_basic userbasic1_ on article0_.user_id=userbasic1_.id where article0_.reply_id=0 and article0_.category_id=14 order by article0_.top_flag desc, article0_.reply_date desc, article0_.publish_date desc
SQLState: HY000
errorCode: 0
messages: could not execute query
[Microsoft][SQLServer 2000 Driver for JDBC]Underlying input stream returned zero bytes

throwableCount: 2
throwables: org.hibernate.exception.GenericJDBCException: could not execute query
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Underlying input stream returned zero bytes


java.sql.SQLException
[Microsoft][SQLServer 2000 Driver for JDBC]Underlying input stream returned zero bytes
SQLState: HY000
errorCode: 0

同样,我在本机调试一点问题都没有,发布到服务器上就会报错误。同样,如果我将hibernate打印的SQL放到服务器的SQL Server中运行,完全没有问题。而且很奇怪的,请看这两个连接:http://ice.163jsp.com/Forum.external?sp=14和http://ice.163jsp.com/Forum.external?sp=13,这是两个BBS的栏目,实际上我是同样的方法和同一个HQL进行查询,只是传不同的栏目ID而已。但是一个正确,一个错误,我非常诧异。
搜索更多相关主题的帖子: sql server 办法 
2006-03-09 17:58
快速回复:『出错』请教sql server连接的两个问题,我实在找不到解决办法
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016312 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved