标签:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.SQLServer2008Dialect</property> <property name="hibernate.connection.username">sa</property> <property name="hibernate.connection.password">sa123</property> <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property> <property name="hibernate.connection.url">jdbc:sqlserver://127.0.0.1:1433;database=hibernate</property> <property name="hibernate.hbm2ddl.auto">update</property> <property name="hibernate.format_sql">true</property> <property name="hibernate.show_sql">true</property> <mapping resource="hibernate/test/pojo/Person.hbm.xml"/> </session-factory> </hibernate-configuration>
跟进hibernate的properties 配置数据库实例文件来看。
## Microsoft Driver (not recommended!) #hibernate.connection.driver_class com.microsoft.jdbc.sqlserver.SQLServerDriver #hibernate.connection.url jdbc:microsoft:sqlserver://1E1;DatabaseName=test;SelectMethod=cursor ## The New Microsoft Driver #hibernate.connection.driver_class com.microsoft.sqlserver.jdbc.SQLServerDriver #hibernate.connection.url jdbc:sqlserver://localhost
第一种方式不被推荐。所以我尝试用第二种方式。结果报错了。错误如下,error1.
Error1 INFO: HHH000115: Hibernate connection pool size: 20 (min=1) Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
第二种方式:按照实例上说的没有 数据库的说明啊。 <property name="hibernate.connection.url">jdbc:sqlserver://127.0.0.1:1433/hibernate</property>
第一种方式:结果成功了。问题到底出在哪里呢??? <property name="hibernate.connection.url">jdbc:sqlserver://127.0.0.1:1433;database=hibernate</property>
我想问一下hibernate推荐的连接sqlsever数据库的方式到底是啥呢?
标签:
原文地址:http://my.oschina.net/u/2308739/blog/405227