【问题标题】:Exception in connection between Hibernate and SQL Server 2005Hibernate 和 SQL Server 2005 之间的连接异常
【发布时间】:2012-07-31 13:23:38
【问题描述】:

我想将我的 java 项目连接到 SQL Server 2005 数据库,但不幸的是我遇到了一些问题。 我正在使用 Windows 身份验证(我的电脑名称是 BOURKADIXP,没有密码),这是我的 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.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
        <property name="hibernate.connection.password">azerty</property>
        <property name="hibernate.connection.url">jdbc:jtds:sqlserver://127.0.0.1/DBM6000</property>
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
    </session-factory>
</hibernate-configuration>

这是我遇到的例外:

 org.hibernate.exception.JDBCConnectionException: Getting database metadata
Getting database metadata
  java.sql.SQLException: Network error IOException: Connection refused: connect
  Network error IOException: Connection refused: connect
    java.sql.SQLException: Network error IOException: Connection refused: connect
    Network error IOException: Connection refused: connect
    java.net.ConnectException: Connection refused: connect
    Connection refused: connect

感谢您的帮助!

【问题讨论】:

    标签: java sql-server hibernate


    【解决方案1】:

    您确定在您的服务器配置中允许 tcp/ip 连接吗? 如果是,请检查您是否使用正确的端口号进行连接。 或者如果你想通过命名管道连接,设置 namedPipe=true; url 字符串中的属性。

    【讨论】:

    • 如何检查tcp/ip是否允许??
    • 我激活了 tcp/ip 连接,我仍然有同样的问题
    • 能否通过telnet连接到 1433?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-05
    • 1970-01-01
    • 2010-11-20
    • 1970-01-01
    • 2012-03-06
    • 1970-01-01
    • 2010-09-18
    相关资源
    最近更新 更多