Hibernate配置连接SQL SERVER2000

今天做了一个用hibernate连接sql server2000数据库的程序,遇到了一些问题,在经过一个多小时的调试下终于解决了.将解决问题方法在这里记录一下备以后查阅:

问题出现的原因就是用微软提供的jar包.在hibernate.cfg.xml文件中也是按照该包的配置方法进行配置,结果总是出错,具体的出错信息就是找不到jar包里的方法.于是把错误消息到网上查找,在一个帖子上发现最好不要用微软提供的jar包,用jtds.jar.于是就上网查找jtds.jar的下载网址,找到后下载部署的工程中.

接下来就是按照jtds.jar的文件方式进行配置hibernate.cfg.xml文件了.配置如下:

xml 代码
  1. <!--sp--&gtxml version='1.0' encoding='utf-8'?>
  2. <!--CTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
  3. "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
  4. <hibernate-configuration>
  5. <session-factory>
  6. <!-- properties --&gt
  7. <!-- define query language constants / function names --&gt
  8. <property name="hibernate.query.substitutions">true 1, false 0, yes 'Y', no 'N'property>
  9. <!--JNDI Datasource --&gt
  10. <!-- property name="hibernate.connection.datasource">java:comp/env/jdbc/docMgrDS
  11. <!-- SqlServer--&gt
  12. <property name="dialect">net.sf.hibernate.dialect.SQLServerDialectproperty>
  13. <!-- net.sf.hibernate.dialect.OracleDialect--&gt
  14. <property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driverproperty>
  15. <!-- oracle.jdbc.driver.OracleDriver--&gt
  16. <property name="hibernate.connection.url">jdbc:jtds:sqlserver://10.64.86.34:1433/eipproperty>
  17. <!-- jdbc:oracle:thin:@192.168.3.6:1521:orcl--&gt
  18. <property name="hibernate.connection.username">saproperty>
  19. <property name="hibernate.connection.password">capinfoproperty>
  20. <!-- Hibernate Connection Pool --&gt
  21. <property name="connection.pool_size">2property>
  22. <property name="statement_cache.size">25property>
  23. <!-- property name="connection.provider_class">net.sf.hibernate.connection.DatasourceConnectionProvider
  24. <property name="connection.provider_class">net.sf.hibernate.connection.DriverManagerConnectionProviderproperty>
  25. <!-- the Transaction API abstracts application code from the underlying JTA or JDBC transactions --&gt
  26. <property name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactoryproperty>
  27. <!-- print all generated SQL to the console --&gt
  28. <property name="show_sql">trueproperty>
  29. <!-- set the JDBC fetch size --&gt
  30. <property name="jdbc.fetch_size">50property>
  31. <!-- set the maximum JDBC 2 batch size (a nonzero value enables batching) --&gt
  32. <property name="jdbc.batch_size">25property>
  33. <!-- enable use of JDBC 2 scrollable ResultSets (specifying a Dialect will cause Hibernate to use a sensible default) --&gt
  34. <property name="hibernate.jdbc.use_scrollable_resultset">falseproperty>
  35. <!-- use streams when writing binary types to / from JDBC --&gt
  36. <property name="jdbc.use_streams_for_binary">trueproperty>
  37. <!-- enable outerjoin fetching (specifying a Dialect will cause Hibernate to use sensible default) --&gt
  38. <property name="use_outer_join">trueproperty>
  39. <!-- --&gt
  40. <property name="max_fetch_depth">1property>
  41. <!-- --&gt
  42. <property name="cache.provider_class">net.sf.hibernate.cache.HashtableCacheProviderproperty>
  43. <!-- --&gt
  44. <property name="hibernate.cache.use_query">trueproperty>
  45. <!-- Mapping files --&gt
  46. <!-- usersys --&gt
  47. <mapping resource="com/capinfo/edu/usersys/UserObject.hbm.xml" />
  48. session-factory>
  49. hibernate-configuration>

配置成功,进行程序,哦了!

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/800861/viewspace-922098/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/800861/viewspace-922098/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值