【问题标题】:How to set Hibernate with sqlserver&jtds driver in Netbeans如何在 Netbeans 中使用 sqlserver&jtds 驱动程序设置休眠
【发布时间】:2011-11-04 10:11:07
【问题描述】:

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

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

我在 WINDOWS\system32 中有 ntlmauth.dll。

【问题讨论】:

  • 您对此有什么解决方案吗?逆向工程向导在使用 jTDS 驱动程序时不执行任何操作,并且与 MS 驱动程序一起工作。

标签: java hibernate netbeans jtds


【解决方案1】:

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

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

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

【讨论】:

  • 不,如果我尝试在没有休眠的情况下连接,jtds 工作正常: Connection con = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:2545/MyDB"))
猜你喜欢
  • 2013-03-09
  • 2018-06-18
  • 2014-01-03
  • 1970-01-01
  • 2018-07-03
  • 2016-11-19
  • 2018-03-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多