xunil

 

关于Hibernate3连接Sqlserver 2005中hibernate.connection配置问题

学习Hibernate3,连接Sqlserver 2005,Eclipse中添加了个Hibernate组件,其中的hibernate.connection.*的配置(自动选择生成),其中的driver_class和url很是让人受伤。

1.hibernate.connection.driver_class=com.microsoft.jdbc.sqlserver.SQLServerDriver (选择生成)

sqljdbc4.jar引入,出现 com.microsoft.jdbc.sqlserver.SQLServerDriver 找不到,传说这是连接Sqlserver 2000中的(未调试),正确的value为com.microsoft.sqlserver.jdbc.SQLServerDriver ,悲剧。

2.hibernate.connection.url=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=database_name (选择生成)

出现:org.hibernate.exception.JDBCConnectionException: Cannot open connection,很久找不到原因,最后在网上一偏僻小角找到,应为:hibernate.connection.url=jdbc:sqlserver://localhost:1433;DatabaseName=database_name。看样子连接SQL Server还是ADO.NET好啊,JDBC毕竟是外人那。

痛并快乐着啊!

posted on 2011-07-12 21:59  xunil  阅读(975)  评论(0编辑  收藏  举报

导航