hibernate配置鏈接sqlsever2008數據庫

<?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"/><!--若是僅僅使用hibernate須要配置映射文件資源-->
    </session-factory>
</hibernate-configuration>

根據hibernate的properties 配置數據庫實例文件來看。
java

## 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.sql

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數據庫的方式究竟是啥呢?數據庫

相關文章
相關標籤/搜索