如何在Netbeans中使用sqlserver和amp; jtds驱动程序设置Hibernate

时间:2011-08-26 10:26:50

标签: java hibernate netbeans jtds

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

sqlserver 2008是localy安装的,没有用户名或密码。

这是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。

1 个答案:

答案 0 :(得分:0)

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属性作为工作站上当前登录的用户登录。

相关问题