0

我想将我的 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

感谢帮助!

4

1 回答 1

0

Are you sure that tcp/ip connections is allowed in your server configuration? If yes, check that you are using correct port number for connection. Or if you want to connect throught named pipe, set namedPipe=true; property in the url string.

于 2012-07-31T14:02:46.933 回答