我正在尝试设置 Netbeans 以使用 jtds 驱动程序连接到 SQLSERVER 2008 与 Hibernate 一起工作。
sqlserver 2008安装在本地,没有用户名和密码。
这是 hibernate.cfg:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
<property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:jtds:sqlserver://localhost:2545/MyDB</property>
</session-factory>
</hibernate-configuration>
当我尝试使用 Hibernate 逆向工程向导设置 Hibernate 逆向工程文件时,出现以下错误:
Unable to connect. Cannot establish a connection to jdbc:jtds:sqlserver://localhost:2545/MyDB using net.sourceforge.jtds.jdbc.Driver (I/O Error: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property.).
我在WINDOWS\system32下有ntlmauth.dll。
最佳答案
jdbc:jtds:sqlserver://localhost:2545/MyDB
似乎是 jTDS 驱动程序的不完整 JDBC URL。
按照 jTDS FAQ 进行,您还需要指定 username
和 password
属性。此外,由于您似乎在 MS SQL Server 2008 中使用集成的 Windows 身份验证,因此您还需要设置 domain
属性。
请注意,必须提供 username
和 password
值,除非您安装了 jTDS SSO 库,即 ntlmauth.dll;因为您已经在您的 PATH 中拥有它,所以您需要指定 domain
属性以作为工作站上当前登录的用户登录。
关于java - 如何在 Netbeans 中使用 sqlserver 和 jtds 驱动程序设置 Hibernate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7203345/