无法在远程系统上使用Windows身份验证连接到MS SQL Server [英] Can not connect to ms sql server using windows authentication on remote system

查看:171
本文介绍了无法在远程系统上使用Windows身份验证连接到MS SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图连接到安装在远程系统上的ms sql server2008.但是它显示错误.以下是我尝试过的方法

I was trying to connect to ms sql server 2008 which is installed on a remote system.But it showing error.The following is the way i had tried

import java.io.File;
import java.sql.Connection;  
import java.sql.DriverManager;  
import java.sql.PreparedStatement;
import java.sql.ResultSet;  
import java.sql.Statement;  


public class mssql {  
    public static void main(String[] args) {  
        try {  
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();

            Connection connection=DriverManager.getConnection("jdbc:sqlserver://192.168.1.220:1433;databaseName=sales;integratedSecurity=true;");
            if(!(connection==null))
            {
                System.out.println("connected");
            }

//            


        } catch (Exception e) {  
            e.printStackTrace();  
        }  
    }  
}  

这是我遇到的错误

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 192.168.1.220, port 1433 has failed. Error: "connect timed out. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
    at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:241)
    at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2243)
    at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:491)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1309)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at mssql.main(mssql.java:14)

任何解决此问题的方法

推荐答案

是否已将2008 SQL实例配置为用于TCP连接的listening?

Is the 2008 SQL instance configured to be listening for TCP connections?

开始,Microsoft SQL Server 2008,配置工具,SQL Server配置管理器 SQL Server网络配置
[实例名称]
的协议 应该列出四个项目:

Start, Microsoft SQL Server 2008, Configuration Tools, SQL Server Configuration Manager SQL Server Network Configuration
Protocols for [instance name]
There should be four items listed:

  • 共享内存
  • 命名管道
  • TCP/IP
  • VIA

对于您的环境,应该启用和禁用哪些?大多数设置都要求启用共享内存"和"TCP/IP",而其他设置则被禁用.

For your environment, which should be enabled and which should be disabled? Most setups call for Shared Memory and TCP/IP enabled, the others disabled.

这篇关于无法在远程系统上使用Windows身份验证连接到MS SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆