2012-07-31 67 views
0

我想將我的java項目連接到SQL Server 2005數據庫,但不幸的是我遇到了一些問題。 我使用Windows身份認證(我的電腦的名字是BOURKADIXP沒有密碼),這裏是我的hibernate.cfg:Hibernate和SQL Server 2005之間的連接異常

<?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 

感謝您的幫助!

回答

0

您確定您的服務器配置允許tcp/ip連接嗎? 如果是,請檢查您是否使用正確的端口號進行連接。 或者如果你想連接命名管道,設置namedPipe = true; url字符串中的屬性。

+0

如何檢查tcp/ip是否允許? – Bourkadi 2012-07-31 14:51:21

+0

我激活了tcp/ip連接,但我仍然遇到同樣的問題 – Bourkadi 2012-07-31 16:05:32

+0

是否可以通過telnet連接 1433? – 2012-07-31 16:54:58