gpt4 book ai didi

java - 无法打开 hibernate 连接

转载 作者:太空宇宙 更新时间:2023-11-04 07:11:26 26 4
gpt4 key购买 nike

我正在使用 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" />

我的电脑userName“user”,并且我通过Windows身份验证连接到SQL,我没有任何密码,因此当我运行应用程序session.beginTransaction()时抛出错误:“用户'user'登录失败。无法打开连接”。有人能解决这个问题吗?

最佳答案

当您想要使用 Windows 身份验证进行连接时,集成安全性应设置为 True:

<property name="hibernate.connection.url">
jdbc:sqlserver://USER-PC:1433;databaseName=AvtoParki;integratedSecurity=true;
</property>

关于java - 无法打开 hibernate 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20593855/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com