我想将我的java项目连接到SQL Server 2005数据库,但不幸的是我遇到了一些问题。 我正在使用Windows Authentification(我的电脑名称是没有密码的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
感谢您的帮助!
答案 0 :(得分:0)
您确定服务器配置中是否允许tcp / ip连接? 如果是,请检查您是否使用正确的端口号进行连接。 或者,如果要通过命名管道连接,请设置namedPipe = true; url字符串中的属性。