2

我正在尝试使用 jtds 驱动程序将 Netbeans 设置为与 Hibernate 一起使用以连接到 SQLSERVER 2008。

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 逆向工程文件时,我收到以下错误:

无法连接。无法使用 net.sourceforge.jtds.jdbc.Driver 建立与 jdbc:jtds:sqlserver://localhost:2545/MyDB 的连接(I/O 错误:SSO 失败:未加载本机 SSPI 库。检查 java.library.path系统属性。)。

我在 WINDOWS\system32 中有 ntlmauth.dll。

4

1 回答 1

0

jdbc:jtds:sqlserver://localhost:2545/MyDB似乎是 jTDS 驱动程序的不完整 JDBC URL。

通过jTDS FAQ,您还需要指定usernamepassword属性。此外,由于您似乎在 MS SQL Server 2008 中使用集成 Windows 身份验证,因此您还需要设置该domain属性。

请注意,除非您安装 jTDS SSO 库,即 ntlmauth.dll,否则必须提供username和值;password由于您已经在 PATH 中拥有它,因此您需要指定domain属性以作为工作站上当前登录的用户登录。

于 2011-08-26T11:03:24.703 回答