java - 无法打开 hibernate 连接

标签 java sql-server 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" />

我的电脑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/

相关文章:

java - JGroupsTransport 类型的对象上的 CacheException :Unable to invoke public void org. infinispan.remoting.transport.jgroups.JGroupsTransport.start()

java - 从 Jsoup 元素对象获取字符串文本

sql - 跨不同环境查询存储过程中的多个数据库的最佳方法是什么

sql-server - 按依赖顺序编写 Sql Server 数据库中所有 View /函数/过程的脚本

java - 多个数据库的 Hibernate 自动递增字段

java - 安心 : How to make the abstract layer for the type of endpoint call

java - 写入 java 子进程

sql - Microsoft SQL Server 2008 外部备份

java - Hibernate.initialize() 被完全忽略

java - 奇怪的java.io.NotSerializedException : org. springframework.dao.support.PersistenceExceptionTranslationInterceptor