`
energykey
  • 浏览: 597548 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

hibernate 连接接SQLSERVER解决方案

阅读更多

今日早上发了个贴子,现在终于有了一套方案,原贴如下:

 

 

DEBUG 2009-03-07 09:49:20,757 | [com.hzjava.xiu.site.web.servlet.MatchAutoServlet]:init | ========MatchAutoServlet启动========
INFO  2009-03-07 09:49:20,835 | [com.hzjava.xiu.site.web.servlet.MatchAutoServlet]:init | ====spring上下文获得成功====
Hibernate: select this_.ID as ID13_0_, this_.NAME as NAME13_0_, this_.KEY_CODE as KEY3_13_0_, this_.price as price13_0_ from ST_SERVICE_PRICE this_
DEBUG 2009-03-07 09:49:20,882 | [com.hzjava.xiu.site.service.ServicePriceServiceImpl]:getSPriceList | 系统服务定价DB同步:3
DEBUG 2009-03-07 09:49:20,882 | [com.hzjava.xiu.site.service.ServicePriceServiceImpl]:getSPriceList | 0.0
DEBUG 2009-03-07 09:49:20,913 | [com.hzjava.xiu.site.web.servlet.MatchAutoServlet$MatchAutoThread]:run | ========系统自动匹配供求信息Start;60*5秒运行一次========
Hibernate: select top 10000 supplyinfo0_.ID as ID6_, supplyinfo0_.userId as userId6_, supplyinfo0_.productId as productId6_, supplyinfo0_.TYPE_ID as TYPE4_6_, supplyinfo0_.billDesc as billDesc6_, supplyinfo0_.kindId as kindId6_, supplyinfo0_.cityId as cityId6_, supplyinfo0_.pic as pic6_, supplyinfo0_.price as price6_, supplyinfo0_.amount as amount6_, supplyinfo0_.yue_lilv as yue11_6_, supplyinfo0_.pubTime as pubTime6_, supplyinfo0_.endTime as endTime6_, supplyinfo0_.IS_Dirty as IS14_6_, supplyinfo0_.O_CONTACT_WAY as O15_6_, supplyinfo0_.qipiaoId as qipiaoId6_, supplyinfo0_.danbiId as danbiId6_, supplyinfo0_.infostateId as infosta18_6_, supplyinfo0_.createTime as createTime6_, supplyinfo0_.releaseTime as release20_6_ from sv_SupplyInfo supplyinfo0_ where 1=1 and supplyinfo0_.infostateId=? and supplyinfo0_.TYPE_ID=? order by supplyinfo0_.ID desc
ERROR 2009-03-07 09:49:20,944 | [org.hibernate.util.JDBCExceptionReporter]:logExceptions | No data found
Exception in thread "Thread-5" org.hibernate.exception.GenericJDBCException: could not execute query
	at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
	at org.hibernate.loader.Loader.doList(Loader.java:2214)
	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
	at org.hibernate.loader.Loader.list(Loader.java:2090)
	at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:388)
	at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
	at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
	at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
	at cn.collin.commons.dao.MyDaoSupport.findByMaxResults(MyDaoSupport.java:274)
	at com.hzjava.xiu.site.dao.SupplyDAOImpl.listByMaxResults(SupplyDAOImpl.java:79)
	at com.hzjava.xiu.site.service.SupplyServiceImpl.newMatchAuto(SupplyServiceImpl.java:169)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at $Proxy5.newMatchAuto(Unknown Source)
	at com.hzjava.xiu.site.web.servlet.MatchAutoServlet$MatchAutoThread.run(MatchAutoServlet.java:57)
Caused by: java.sql.SQLException: No data found
	at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7139)
	at sun.jdbc.odbc.JdbcOdbc.SQLGetDataDouble(JdbcOdbc.java:3658)
	at sun.jdbc.odbc.JdbcOdbcResultSet.getDataDouble(JdbcOdbcResultSet.java:5576)
	at sun.jdbc.odbc.JdbcOdbcResultSet.getLong(JdbcOdbcResultSet.java:632)
	at sun.jdbc.odbc.JdbcOdbcResultSet.getLong(JdbcOdbcResultSet.java:650)
	at org.apache.commons.dbcp.DelegatingResultSet.getLong(DelegatingResultSet.java:240)
	at org.hibernate.type.LongType.get(LongType.java:28)
	at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)
	at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102)
	at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
	at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2046)
	at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1371)
	at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1299)
	at org.hibernate.loader.Loader.getRow(Loader.java:1197)
	at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:568)
	at org.hibernate.loader.Loader.doQuery(Loader.java:689)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
	at org.hibernate.loader.Loader.doList(Loader.java:2211)
 

因为一直使用的是Mysql.现在做了个网站因为客户端软件采用C#开发的,所以为了配合软件数据库采用SQLSERVER。而昨天采用jdbc直连的方式没有成功【数据库已连接,但查询不出数据,SP4补丁已打!Jar包已有!】

 

先看看ODBC的配置文件吧

#-----------ODBC------
jdbc.driverClassName=sun.jdbc.odbc.JdbcOdbcDriver
jdbc.url=jdbc:odbc:supply
jdbc.password=123456
jdbc.username=sa

jdbc.initialSize=1
jdbc.maxActive=20
jdbc.maxIdle=10
jdbc.maxWait=120000
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
hibernate.show_sql=true
hibernate.jdbc.batch_size=20
hibernate.connection.pool_size=20

 这个不用说了,ODBC数据源建了的,ODBC是连接成功了的。

在这一步可以看出:

DEBUG 2009-03-07 09:49:20,882 | [com.hzjava.xiu.site.service.ServicePriceServiceImpl]:getSPriceList | 系统服务定价DB同步:3
DEBUG 2009-03-07 09:49:20,882 | [com.hzjava.xiu.site.service.ServicePriceServiceImpl]:getSPriceList | 0.0

 做DB同步时查询出来的LIST为3!说明连接成功了并且执行错误了。

这个JDBC的错误我看懂了,就是说Hibernate在做ORM的时候,因为我查询的这张表里存在NULL的数据,而HIBERNATE在rs那里采用rs.getLong()等等的时候就报错了。

at sun.jdbc.odbc.JdbcOdbcResultSet.getDataDouble(JdbcOdbcResultSet.java:5576)
	at sun.jdbc.odbc.JdbcOdbcResultSet.getLong(JdbcOdbcResultSet.java:632)
	at sun.jdbc.odbc.JdbcOdbcResultSet.getLong(JdbcOdbcResultSet.java:650)
	at org.apache.commons.dbcp.DelegatingResultSet.getLong(DelegatingResultSet.java:240)
	at org.hibernate.type.LongType.get(LongType.java:28)
	at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)
	at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102)

 我的查询语句没有问题,全都是HIBERNATE方言生成,我拿到数据库去执行了一次,能够得出正确的结果。问题就是,

rs.getLong("cityId"),比如cityId这一列在数据库中为NULL,这样的写法就会导致SQL异常么?如果是这样,那Hibernate怎么解决这个问题呢?因为做ORM映射肯定是要每个列都要GET的。。。

 

 

!谢谢!

 

另外JDBC直连的方式DB同步的时候结果为0,查询不出任何数据,任何表都一样。我不知道为什么。。。

SPRING配置文件没有问题的,部分代码

<!-- datasource -->
	<bean id="dataSource"
		class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName">
			<value>${jdbc.driverClassName}</value>
		</property>
		<property name="url">
			<value>${jdbc.url}</value>
		</property>
		<property name="username">
			<value>${jdbc.username}</value>
		</property>
		<property name="password">
			<value>${jdbc.password}</value>
		</property>
		<property name="initialSize">
			<value>${jdbc.initialSize}</value>
		</property>
		<property name="maxActive">
			<value>${jdbc.maxActive}</value>
		</property>
		<property name="maxIdle">
			<value>${jdbc.maxIdle}</value>
		</property>
		<property name="maxWait">
			<value>${jdbc.maxWait}</value>
		</property>
	</bean>

 CONFIG文件:

#-----------SQLSERVER------
jdbc.driverClassName=com.microsoft.jdbc.sqlserver.SQLServerDriver
jdbc.url=jdbc:sqlserver://localhost:1433;databseName=supply?useUnicode=true&characterEncoding=UTF-8&serverTimezone=+00:00&autoReconnect=true&autoReconnectForPools=true
jdbc.password=123456
jdbc.username=sa

jdbc.initialSize=1
jdbc.maxActive=20
jdbc.maxIdle=10
jdbc.maxWait=120000
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
hibernate.show_sql=true
hibernate.jdbc.batch_size=20
hibernate.connection.pool_size=20

 SP4已打,三个JAR包已有。在线&等!!!感谢!!!

 

以上为上午所发的贴子。。

 

 

晚上逛论坛的收获:

http://www.iteye.com/topic/7407

bluemeteor写道
微软看到这个标题,肯定不高兴了。不过说实话,在商业应用中,很少有公司真正实用微软的那个什么com.microsoft.jdbc.sqlserver.SQLServerDriver。


??? 其实发现微软驱动的不足,也是很偶然的机会。在一次移植应用中,系统报告了[Microsoft][SQLServer JDBC Driver]ResultSet can not re-read row data for column之类的错误。为了解决这个错误,跟踪程序忙了大半天,也没有查出问题所在。只能确定在在rs.getString("XXX")的时候必然会出现错误(rs为ResultSet对象)。那么现在就模拟以下当时的环境:
??? 数据库表:TestTable
??? 表字段及类型:
???????? guid char(38)
???????? title varchar(100)
???????? content Text
???????? username varchar(20)
??? 查询sql语句:
???????? select guid,username,content,title from TestTable where····
??? java代码:
???????? rs.getString("guid");
???????? rs.getBinaryStream("content");
???????? rs.getString("username");
??? -----------------------------------------------------------


??? 上面那段代码,很不荣幸是。使用微软的驱动,必然会报错(就是上面说的那个错误)。如果你跟踪的话,必然是这一行:rs.getString("username")抛出错误。


??? 那么,如果你把rs.getString("username")和rs.getBinaryStream("content");位置互换以下,会怎么样呢。结果就是可以正常运行。


??? 为什么会出现这种情况呢,因为微软的驱动,在包含了blob或clob类型(就是Image和Text类型)的字段。那么就必须按照select顺序查询,且不支持重复查询。


?? 面对这种情况,只有更换驱动了。国外第三方的驱动很多,比如JSQLConnect,JTurbo等等。这些都是商用的,需要付费,不够有试用版本。如果希望有个免费的,可以在www.freetds.com上获取一个免费的(我没有测试过这个免费驱动,不知道是否会存在这种情况)。
?
有关最初的说明,可以参考[javasearch]
http://www.javaresearch.org/article/showarticle.jsp?column=2&thread=4278]
或[javaunion](很遗憾的是,javaunion已经不存在了)
http://www.javaunion.org/bbs/cgi-bin/topic.cgi?forum=1&topic=15516&show=0


??? 其实今天想说的这篇文档真的有些老了。早在曾经的javaunion还存在的时候就谈过这样的问题了。今天突然又贴出来,只是偶然间发现了数据库板块中的 “SQLServer2000 JDBC驱动的完整安装及测试说明”这篇文档。我以为会有些什么值得参考的东东,结果大失所望(文章很适合入门型的参考,从这一点上写的还是可以的)。不过,拿来商业性应用中,就有些幼稚了。
??? 希望大家慎用或尽量不要用微软自带的sqlserver的jdbc驱动。
??? 如果有什么疑问,或有错误地方,请斧正。可以发邮件,相互交流。



作者:银狐999(james999)
信箱:james-fly@vip.sina.com

===============================================
接受blundblade兄弟的建议,补充如下:

(1)如果采用jdbc-odbc驱动,那么就必须按照查询顺序来一次读取(不论有没有image或text类型)
(2)如果采用微软提供的ms sql server jdbc driver,如果查询语句中,不存在image或text类型字段,那么可以按照无序获取
(3)如果采用微软提供的ms sql server jdbc driver,如果查询语句中,存在image或text类型字段,那么就必须按照顺序读取,否则就会报告Driver]ResultSet can not re-read row data for column之类的错误
(4)如果想不查询语句中有没有image或text类型字段,都可以不按照顺序获取,或重复获取。那么就必须更换驱动,改用第三方的。


楼主主要是涉及到两表联立查询了 所以单个查询即可

只是把一条SQL拆成两条了 没办法 B4微软吧

 

Readonly 写道
使用M$默认的driver
需要在connection url后面加上SelectMethod=cursor
可以解决re-read的问题.

但是还是不推荐使用这个性能糟糕的driver,

使用jtds吧, pass all hibernate test case, open source:
http://sourceforge.net/projects/jtds/

 

 

感谢readonly给出的建议,我到jtds的官网浏览并下载了jtds,看了下文档,下面说下我的配置步骤【hibernate测试通过】

 

首先下载jtds,然后将jtds-1.2.2.jar复制到lib目录下,

 

接着-》config.properties:

#-----------SQLSERVER------
jdbc.driverClassName=net.sourceforge.jtds.jdbc.Driver
jdbc.url=jdbc:jtds:sqlserver://ipaddress:1433/supply
jdbc.password=password
jdbc.username=sa

jdbc.initialSize=1
jdbc.maxActive=20
jdbc.maxIdle=10
jdbc.maxWait=120000
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
hibernate.show_sql=true
hibernate.jdbc.batch_size=20
hibernate.connection.pool_size=20

 密码和ip请根据自己的设置更改。

测试成功,console显示:

 

Hibernate: select banks0_.SUPPLY_ID as SUPPLY3_1_, banks0_.ID as ID1_, banks0_.ID as ID5_0_, banks0_.BANK_ID as BANK2_5_0_, banks0_.SUPPLY_ID as SUPPLY3_5_0_, banks0_.MAIDUAN as MAIDUAN5_0_, banks0_.HUIGOU as HUIGOU5_0_ from st_BANK banks0_ where banks0_.SUPPLY_ID=?
Hibernate: select top 10000 supplyinfo0_.ID as ID6_, supplyinfo0_.userId as userId6_, supplyinfo0_.productId as productId6_, supplyinfo0_.TYPE_ID as TYPE4_6_, supplyinfo0_.billDesc as billDesc6_, supplyinfo0_.kindId as kindId6_, supplyinfo0_.cityId as cityId6_, supplyinfo0_.pic as pic6_, supplyinfo0_.price as price6_, supplyinfo0_.amount as amount6_, supplyinfo0_.yue_lilv as yue11_6_, supplyinfo0_.pubTime as pubTime6_, supplyinfo0_.endTime as endTime6_, supplyinfo0_.IS_Dirty as IS14_6_, supplyinfo0_.O_CONTACT_WAY as O15_6_, supplyinfo0_.qipiaoId as qipiaoId6_, supplyinfo0_.danbiId as danbiId6_, supplyinfo0_.infostateId as infosta18_6_, supplyinfo0_.createTime as createTime6_, supplyinfo0_.releaseTime as release20_6_ from sv_SupplyInfo supplyinfo0_ where 1=1 and supplyinfo0_.TYPE_ID=? and supplyinfo0_.infostateId=? and supplyinfo0_.productId=? and supplyinfo0_.yue_lilv>=? order by supplyinfo0_.ID desc
Hibernate: select banks0_.SUPPLY_ID as SUPPLY3_1_, banks0_.ID as ID1_, banks0_.ID as ID5_0_, banks0_.BANK_ID as BANK2_5_0_, banks0_.SUPPLY_ID as SUPPLY3_5_0_, banks0_.MAIDUAN as MAIDUAN5_0_, banks0_.HUIGOU as HUIGOU5_0_ from st_BANK banks0_ where banks0_.SUPPLY_ID=?
Hibernate: select count(*) as col_0_0_ from ST_MATCH match0_ where 1=1 and match0_.SELL_ID=? and match0_.BUY_ID=?
DEBUG 2009-03-07 23:49:09,375 | [org.hibernate.cache.UpdateTimestampsCache]:preinvalidate | Pre-invalidating space [ST_MATCH]
Hibernate: insert into ST_MATCH (SELL_ID, BUY_ID, STATE_ID, CREATED_TIME) values (?, ?, ?, ?)
DEBUG 2009-03-07 23:49:09,781 | [com.hzjava.xiu.site.service.SupplyServiceImpl]:newMatchAuto | =========共匹配到1信息========
DEBUG 2009-03-07 23:49:09,875 | [org.hibernate.cache.UpdateTimestampsCache]:invalidate | Invalidating space [ST_MATCH], timestamp: 5064462130688000
DEBUG 2009-03-07 23:49:46,812 | [com.hzjava.wibo.site.service.HierInfoService]:findHierInfo | SV_ZX_BOOKING_CHARGE_DAY:id = 15000
DEBUG 2009-03-07 23:49:46,812 | [com.hzjava.wibo.site.service.HierInfoService]:findHierInfo | SV_ZX_BOOKING_CHARGE_DAY:id = 15000
DEBUG 2009-03-07 23:54:09,875 | [com.hzjava.xiu.site.web.servlet.MatchAutoServlet$MatchAutoThread]:run | ========系统自动匹配供求信息Start;60*5秒运行一次========
Hibernate: select top 10000 supplyinfo0_.ID as ID6_, supplyinfo0_.userId as userId6_, supplyinfo0_.productId as productId6_, supplyinfo0_.TYPE_ID as TYPE4_6_, supplyinfo0_.billDesc as billDesc6_, supplyinfo0_.kindId as kindId6_, supplyinfo0_.cityId as cityId6_, supplyinfo0_.pic as pic6_, supplyinfo0_.price as price6_, supplyinfo0_.amount as amount6_, supplyinfo0_.yue_lilv as yue11_6_, supplyinfo0_.pubTime as pubTime6_, supplyinfo0_.endTime as endTime6_, supplyinfo0_.IS_Dirty as IS14_6_, supplyinfo0_.O_CONTACT_WAY as O15_6_, supplyinfo0_.qipiaoId as qipiaoId6_, supplyinfo0_.danbiId as danbiId6_, supplyinfo0_.infostateId as infosta18_6_, supplyinfo0_.createTime as createTime6_, supplyinfo0_.releaseTime as release20_6_ from sv_SupplyInfo supplyinfo0_ where 1=1 and supplyinfo0_.infostateId=? and supplyinfo0_.TYPE_ID=? order by supplyinfo0_.ID desc
Hibernate: select banks0_.SUPPLY_ID as SUPPLY3_1_, banks0_.ID as ID1_, banks0_.ID as ID5_0_, banks0_.BANK_ID as BANK2_5_0_, banks0_.SUPPLY_ID as SUPPLY3_5_0_, banks0_.MAIDUAN as MAIDUAN5_0_, banks0_.HUIGOU as HUIGOU5_0_ from st_BANK banks0_ where banks0_.SUPPLY_ID=?
Hibernate: select top 10000 supplyinfo0_.ID as ID6_, supplyinfo0_.userId as userId6_, supplyinfo0_.productId as productId6_, supplyinfo0_.TYPE_ID as TYPE4_6_, supplyinfo0_.billDesc as billDesc6_, supplyinfo0_.kindId as kindId6_, supplyinfo0_.cityId as cityId6_, supplyinfo0_.pic as pic6_, supplyinfo0_.price as price6_, supplyinfo0_.amount as amount6_, supplyinfo0_.yue_lilv as yue11_6_, supplyinfo0_.pubTime as pubTime6_, supplyinfo0_.endTime as endTime6_, supplyinfo0_.IS_Dirty as IS14_6_, supplyinfo0_.O_CONTACT_WAY as O15_6_, supplyinfo0_.qipiaoId as qipiaoId6_, supplyinfo0_.danbiId as danbiId6_, supplyinfo0_.infostateId as infosta18_6_, supplyinfo0_.createTime as createTime6_, supplyinfo0_.releaseTime as release20_6_ from sv_SupplyInfo supplyinfo0_ where 1=1 and supplyinfo0_.TYPE_ID=? and supplyinfo0_.infostateId=? and supplyinfo0_.productId=? and supplyinfo0_.yue_lilv>=? order by supplyinfo0_.ID desc
Hibernate: select banks0_.SUPPLY_ID as SUPPLY3_1_, banks0_.ID as ID1_, banks0_.ID as ID5_0_, banks0_.BANK_ID as BANK2_5_0_, banks0_.SUPPLY_ID as SUPPLY3_5_0_, banks0_.MAIDUAN as MAIDUAN5_0_, banks0_.HUIGOU as HUIGOU5_0_ from st_BANK banks0_ where banks0_.SUPPLY_ID=?
Hibernate: select count(*) as col_0_0_ from ST_MATCH match0_ where 1=1 and match0_.SELL_ID=? and match0_.BUY_ID=?
DEBUG 2009-03-07 23:54:15,156 | [com.hzjava.xiu.site.service.SupplyServiceImpl]:newMatchAuto | =========匹配结果已存在========
DEBUG 2009-03-07 23:54:15,156 | [com.hzjava.xiu.site.service.SupplyServiceImpl]:newMatchAuto | =========共匹配到0信息========
DEBUG 2009-03-07 23:59:16,250 | [com.hzjava.xiu.site.web.servlet.MatchAutoServlet$MatchAutoThread]:run | ========系统自动匹配供求信息Start;60*5秒运行一次========
Hibernate: select top 10000 supplyinfo0_.ID as ID6_, supplyinfo0_.userId as userId6_, supplyinfo0_.productId as productId6_, supplyinfo0_.TYPE_ID as TYPE4_6_, supplyinfo0_.billDesc as billDesc6_, supplyinfo0_.kindId as kindId6_, supplyinfo0_.cityId as cityId6_, supplyinfo0_.pic as pic6_, supplyinfo0_.price as price6_, supplyinfo0_.amount as amount6_, supplyinfo0_.yue_lilv as yue11_6_, supplyinfo0_.pubTime as pubTime6_, supplyinfo0_.endTime as endTime6_, supplyinfo0_.IS_Dirty as IS14_6_, supplyinfo0_.O_CONTACT_WAY as O15_6_, supplyinfo0_.qipiaoId as qipiaoId6_, supplyinfo0_.danbiId as danbiId6_, supplyinfo0_.infostateId as infosta18_6_, supplyinfo0_.createTime as createTime6_, supplyinfo0_.releaseTime as release20_6_ from sv_SupplyInfo supplyinfo0_ where 1=1 and supplyinfo0_.infostateId=? and supplyinfo0_.TYPE_ID=? order by supplyinfo0_.ID desc
Hibernate: select banks0_.SUPPLY_ID as SUPPLY3_1_, banks0_.ID as ID1_, banks0_.ID as ID5_0_, banks0_.BANK_ID as BANK2_5_0_, banks0_.SUPPLY_ID as SUPPLY3_5_0_, banks0_.MAIDUAN as MAIDUAN5_0_, banks0_.HUIGOU as HUIGOU5_0_ from st_BANK banks0_ where banks0_.SUPPLY_ID=?
Hibernate: select top 10000 supplyinfo0_.ID as ID6_, supplyinfo0_.userId as userId6_, supplyinfo0_.productId as productId6_, supplyinfo0_.TYPE_ID as TYPE4_6_, supplyinfo0_.billDesc as billDesc6_, supplyinfo0_.kindId as kindId6_, supplyinfo0_.cityId as cityId6_, supplyinfo0_.pic as pic6_, supplyinfo0_.price as price6_, supplyinfo0_.amount as amount6_, supplyinfo0_.yue_lilv as yue11_6_, supplyinfo0_.pubTime as pubTime6_, supplyinfo0_.endTime as endTime6_, supplyinfo0_.IS_Dirty as IS14_6_, supplyinfo0_.O_CONTACT_WAY as O15_6_, supplyinfo0_.qipiaoId as qipiaoId6_, supplyinfo0_.danbiId as danbiId6_, supplyinfo0_.infostateId as infosta18_6_, supplyinfo0_.createTime as createTime6_, supplyinfo0_.releaseTime as release20_6_ from sv_SupplyInfo supplyinfo0_ where 1=1 and supplyinfo0_.TYPE_ID=? and supplyinfo0_.infostateId=? and supplyinfo0_.productId=? and supplyinfo0_.yue_lilv>=? order by supplyinfo0_.ID desc
Hibernate: select banks0_.SUPPLY_ID as SUPPLY3_1_, banks0_.ID as ID1_, banks0_.ID as ID5_0_, banks0_.BANK_ID as BANK2_5_0_, banks0_.SUPPLY_ID as SUPPLY3_5_0_, banks0_.MAIDUAN as MAIDUAN5_0_, banks0_.HUIGOU as HUIGOU5_0_ from st_BANK banks0_ where banks0_.SUPPLY_ID=?
Hibernate: select count(*) as col_0_0_ from ST_MATCH match0_ where 1=1 and match0_.SELL_ID=? and match0_.BUY_ID=?
DEBUG 2009-03-07 23:59:16,828 | [com.hzjava.xiu.site.service.SupplyServiceImpl]:newMatchAuto | =========匹配结果已存在========
DEBUG 2009-03-07 23:59:16,828 | [com.hzjava.xiu.site.service.SupplyServiceImpl]:newMatchAuto | =========共匹配到0信息========

 

看来jtds的确是个好东东···呵呵。如果有用的朋友希望可以一起交流。

 

 

最后,如果你觉得本文对你有帮助,请别吝啬您的文字,本人保证以上所有代码都为真实测试,如有遗漏,忘请指正!

分享到:
评论

相关推荐

    SpringBoot+hibernate+mysql+sqlserver双数据源

    总的来说,"SpringBoot+Hibernate+MySQL+SQLServer双数据源"项目展示了如何在Java环境中灵活处理多数据库的需求,为复杂的企业级应用提供了可靠的解决方案。通过理解并掌握这些技术,开发者可以提升自己的技能,应对...

    Hibernate+c3p0连接池SQLServer 2000

    解决方案** 针对出现的连接重置问题,可以通过以下方式来解决: - **设置自动提交模式**:默认情况下,Hibernate会将所有事务设置为非自动提交模式。对于SQL Server 2000来说,在非自动提交模式下,每次执行查询...

    com.microsoft.sqlserver.jdbc.SQLServerException: 只进结果集不支持请求的操作 解决方案

    本文将深入探讨标题和描述中提到的“com.microsoft.sqlserver.jdbc.SQLServerException: 只进结果集不支持请求的操作”这一异常,以及如何在使用Hibernate、Struts进行分页时避免这一问题。我们将从异常的根本原因...

    SSH2整合(Struts2+Spring+Hibernate)+SQL Server2008案例

    在这个案例中,SSH2与SQL Server2008数据库结合,提供了完整的MVC(模型-视图-控制器)架构和数据持久化解决方案。 Struts2作为MVC框架的一部分,负责处理HTTP请求和控制应用程序流程。它通过Action类和配置文件...

    SQL Server 2000 JDBC 驱动jar包(msbase.jar)

    SQL Server 2000 JDBC驱动属于Type 2,它结合了Java和数据库特定的API,提供了一个混合的纯Java和本地代码的解决方案。这种类型的驱动通常比Type 1(纯Java驱动)性能更好,但不如Type 4(完全基于Java的驱动)跨...

    Eclipse创建的JSP文件链接SQLServer2012,Oracle,mysql的方法.rar

    1. **连接SQLServer2012**: - 首先,确保你的系统已经安装了JDBC驱动(Microsoft SQL JDBC Driver)。可以在微软官方网站下载并添加到Eclipse的类路径中。 - 在JSP文件中,使用Java的`Class.forName()`方法加载...

    SSH2+JQUERY+ajax+sqlserver数据库

    标题中的"SSH2+JQUERY+ajax+sqlserver数据库"是一个综合性的技术组合,涉及到Web开发的多个层面,包括服务器端、客户端以及数据存储。让我们逐一解析这些技术及其在实际应用中的作用。 **SSH2(Struts2 + Spring + ...

    进销存管理系统代码和Sql Server数据库

    3. **JDBC**:Java Database Connectivity (JDBC) 是Java连接Sql Server数据库的主要方式,通过JDBC驱动,程序可以进行数据的增删改查操作。 4. **Spring框架**:可能采用了Spring框架来管理依赖关系,提供事务控制...

    java+sql server, 图书借阅管理系统,源程序+数据库+代码

    本系统基于Java编程语言与SQL Server数据库,构建了一套完整的图书借阅管理解决方案。Java以其强大的跨平台能力和丰富的类库,成为开发此类系统的理想选择;而SQL Server作为企业级的关系型数据库管理系统,能够确保...

    Hibernate 多数据库支持解决方案

    6. **Oracle转换到SQL Server 2000注意事项** - 这种转换可能涉及到数据类型、SQL语法、存储过程、触发器等的差异。在迁移过程中,需要对表结构、索引、视图、存储过程等进行相应的调整,确保它们在新数据库中能...

    OA网络自动化办公SSH+sqlserver+ajax+jquery

    **OA网络自动化办公系统**是基于SSH(Struts、Spring、Hibernate)三层架构设计的,它结合了SQL Server 2005数据库以及jQuery和Ajax技术,旨在提供高效、便捷的办公自动化解决方案。 **SSH框架详解:** 1. **Struts...

    连接各种数据库的源代码资料

    Java连接SQL Server主要依赖于JDBC驱动,如Microsoft JDBC Driver for SQL Server。连接过程包括加载驱动、设置数据库URL、用户名和密码,然后建立连接。 5. **MongoDB数据库连接**:MongoDB是非关系型数据库,适用...

    MVC.rar_MYSQL_java sql server_mvc_mvc sql_mysql mvc

    5. **SQL Server**:SQL Server是微软公司开发的一款商业数据库系统,提供强大的企业级功能,包括高可用性、安全性以及数据仓库解决方案,适用于大型企业。 文件名中包含"mvc_sql",这可能意味着教程会涉及SQL查询...

    Growing_SQL_Server_Infographic ZH CN

    9. **高可用性与灾难恢复**:讨论SQL Server的高可用性解决方案,如镜像、复制、Always On Availability Groups等,以及如何设计灾难恢复计划。 10. **最佳实践**:总结在SQL Server管理和开发中的常见最佳实践,...

    订餐系统(Java+SQL server)

    5. **文档编写**:包括课程设计报告,详述系统的设计思路、实现方法以及遇到的问题和解决方案。 通过这个项目,学生可以全面了解Web应用的开发流程,提升Java编程、数据库设计及管理的能力,并实践软件工程中的各种...

    struts2.16 spring2.56 hibernate3.2 sqljdbc4 完整jar包

    Struts2负责控制流程,Spring处理依赖注入和事务管理,Hibernate则作为数据持久层的解决方案,而sqljdbc4.jar则是连接这些组件与SQL Server数据库的桥梁。 在实际项目中,这四个组件的整合使用可以帮助开发者快速...

    C#Hibernate数据库海量读写快速存储

    五、远程服务器的挑战与解决方案: 在远程服务器上进行数据库操作,网络延迟会成为性能瓶颈。为优化性能,可以采取以下策略: 1. 数据库复制:设置数据库镜像或读写分离,将读操作分散到多个副本服务器上。 2. 异步...

    基于JAVA和SQL SERVER数据库实现的医院病房信息管理系统2.7z

    标题中的“基于JAVA和SQL SERVER数据库实现的医院病房信息管理系统”揭示了这是一个使用...这个医院病房信息管理系统结合了Java的开发能力和SQL Server的数据管理优势,为医院提供了一套高效、可靠的信息化解决方案。

    各种数据库架包及连接数据库代码

    本资源包含了一系列针对不同数据库的架包和连接数据库的代码,适用于多种环境,包括SQLServer2000、SQLServer2005、MySQL、Oracle以及DWR和Hibernate。下面将详细介绍这些知识点。 1. **SQLServer**:微软公司开发...

    jtds-1.2.5-dist

    例如,URL应改为`jdbc:jtds:sqlserver://servername:port/databasename`格式。 4. **测试连接**:完成上述步骤后,进行测试以确保新的驱动能够成功连接并执行SQL查询。 "jtds-1.2.5-dist"压缩包很可能包含了jtds...

Global site tag (gtag.js) - Google Analytics