[英]Could not open connection hibernate
我正在使用Hibernate連接到MSSQL 2012,我有cfg.xml
這樣的
<property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:sqlserver://USER-PC:1433;databaseName=AvtoParki;integratedSecurity=false databaseName=AvtoParki;integratedSecurity=false</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password"></property>-->
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.hbm2ddl.auto">create-drop</property>
<!-- Mapping files -->
<mapping class="Employee" />
我的PC userName
是"user"
,並且我正在通過Windows身份驗證連接到SQL,因此我沒有任何密碼,因此,當我運行應用程序session.beginTransaction()
會引發錯誤: "Login failed for user 'user'. Couldn't open connection"
。 誰能解決這個問題?
要使用Windows身份驗證進行連接,應將集成安全性設置為True:
<property name="hibernate.connection.url">
jdbc:sqlserver://USER-PC:1433;databaseName=AvtoParki;integratedSecurity=true;
</property>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.