com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed

后端 未结 4 1697
梦毁少年i
梦毁少年i 2020-11-29 08:17

I keep on getting this error. I tried one solution from stackoverflow (below) which did not work for me - SQL Exception while connecting to SQL server

I tried allow

相关标签:
4条回答
  • 2020-11-29 08:52

    Steps

    • Open the Sql Server Configuration Manager (Start -> Programs -> Microsoft SQL Server 2008 -> Configuration Tools)

    • Expand SQL Server Network Configuration -> [Your Server Instance]

    • Double click TCP/IP

    • Under Protocol:

    • Ensure Enabled is Yes

    • Under IP Addresses:

    • Scroll to the bottom and set the TCP Port under IPAll, (1433 by default)

    • Find the IP address you want to connect to and set Enabled and Active to Yes

    0 讨论(0)
  • 2020-11-29 08:54

    You need to Go to Start > Microsoft SQL Server > Configuration Tools > SQL Server Configuration Manager

    When it opens Go to

    SQL Server Configuration Manager > SQL Server Network Configuration > Protocols for SQLExpress 
    

    Where you'll find the Protocol TCP/IP, if disabled then Enable it Click on TCP/IP, You'll find its properties.

    In this properties Remove All the TCP Dynamic Ports and Add value of 1433 to all TCP Port
    and restart your SQL Server Services > SQL Server

    And Its Done.

    0 讨论(0)
  • 2020-11-29 09:05

    To query database SQL Server with JDBC

    Firstly, You need to find out the IP of your SQL Server and Enable TCP/IP and set TCP/IP port either. To do that, do these steps:

    • Open SQL Server Configuration Manager

      • Choose SQL Server Network Configuration -> Protocols for -> Right click on TCP/IP -> select Enable (if already enabled then move to next step) -> Right click to TCP/IP again -> Properties -> Choose tab IP Address -> In IPAll group: Clear value of TCP Dynamic Ports and set 1433 to TCP Port -> Click OK

        Note: Copy one of the IPs in the Properties table to do config later

      • Double click to SQL Server Services - > Right click to SQL Server (USER) ** -> Choose **Restart

    Now, you already have the IP, config server as below:

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
            <property name="url" value="jdbc:sqlserver://put.the.ip.here:1433;databaseName=<DB-Name>" />
            <property name="username" value="sa" />
            <property name="password" value="p@ssW0rd" />
    </bean>
    

    Note: Remove destroy-method="close" out of the bean

    0 讨论(0)
  • 2020-11-29 09:07

    be sure tha in connectionUrl, your slash is oriented to left like this:

    String connectionUrl = "jdbc:sqlserver://localhost**\**itis;databaseName=dbMediaStore;user=;password=";

    0 讨论(0)
提交回复
热议问题