我在java中使用persistence.xml
建立了与mssql的连接。为此,我必须将sqljdbc_auth.dll
复制到system32,因为我想使用Windows身份验证才能连接。有没有办法在不复制dll文件的情况下实现相同的结果?删除dll会导致此警告并阻止执行:
Failed to load the sqljdbc_auth.dll cause : no sqljdbc_auth in java.library.path
这是我的坚持:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="migration">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>migration.xcs.model.Kennzahl</class>
<properties>
<property name="javax.persistence.jdbc.driver"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />
<property name="javax.persistence.jdbc.url"
value="jdbc:sqlserver://localhost:1433;databaseName=kendb;integratedSecurity=true;" />
<property name="hibernate.archive.autodetection" value="class" />
</properties>
</persistence-unit>
这些是我的pom依赖:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.5.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.0.5.Final</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
答案 0 :(得分:2)
您尚未添加sqljdbc_auth.dll
所在的路径
找出DLL所在的系统,并将其添加到classpath
。
或者在你的Eclipse中,你可以Run Configuration
这样:
-Djava.library.path=C:\path of the dll\