【问题标题】:SQL Server Windows Authentication and HibernateSQL Server Windows 身份验证和休眠
【发布时间】:2017-03-29 12:21:13
【问题描述】:

尝试使用 Hibernate 4.3 连接到具有 Windows 身份验证的 SQL Server,我得到:

“没有名为 instanceTest 的 EntityManager 的持久性提供程序”

我已经加载了 sqljdbc_auth.dll 库,并且我正在使用这个 url:

jdbc:sqlserver://localhost:1433;databaseName=WIN_AUTHDB;integratedSecurity=true

我用来创建实体管理器工厂的参数是:

properties.put("background-validation", "true");
properties.put("hibernate.c3p0.idle_test_period", "3600");
properties.put("hibernate.hbm2ddl.auto", "update");
properties.put("hibernate.max_fetch_depth", "3");
properties.put("hibernate.connection.driver_class", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
properties.put("hibernate.connection.url","jdbc:sqlserver://localhost:1433;databaseName=WIN_AUTHDB;integratedSecurity=true");

我错过了什么?也许没有加载dll?在这一行抛出错误:

Persistence.createEntityManagerFactory("instanceTest", initProperties(properties));

数据库已正确配置,我已通过 Windows 身份验证与 SQL Server 管理连接。另外,在之前的测试中,我实现了在没有休眠的情况下使用驱动程序创建数据库。

提前致谢。

【问题讨论】:

    标签: sql-server hibernate windows-authentication hibernate-entitymanager


    【解决方案1】:

    除此之外,添加以下属性

    properties.put("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect");
    

    【讨论】:

      【解决方案2】:

      已解决!

      比我想象的要简单得多。当我编译 maven 项目时,我无意中删除了 persistence.xml 文件。这就是原因,因为它在战争中从未找到持久性提供者。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-03-06
        相关资源
        最近更新 更多