【发布时间】: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