TCP/IP connection failure when trying to connect to an SQL Server database

Asked

Viewed 1,117 times

0

The code I made was a basic Microsoft example of how to make the connection. The driver is already installed.

package connection;

import javax.swing.*;
import java.sql.*;
import com.microsoft.sqlserver.jdbc.SQLServerDriver;

public class conexao {

    public static void main(String[] args) throws Exception {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

        String connectionUrl = "jdbc:sqlserver://localhost:1433;" + "databaseName=pessoas;user=sa;password=root;";

        Connection con = DriverManager.getConnection(connectionUrl);

    }
}

The mistake:

Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: Falha na conexão TCP/IP com o host localhost, porta 1433.
Erro: "Connect timed out. Verifique as propriedades da conexão.
Verifique se uma instância do SQL Server está sendo executada no host e se está aceitando conexões TCP/IP na porta.
Verifique se as conexões TCP na porta não foram bloqueadas por um firewall.".

3 answers

1

It is a really simple mistake to understand if you have notions of computer networks and apply a little deduction, even more that it is almost all in Portuguese. Switching in kids, the application tried to establish connection to the local database server (installed on the same machine) and failed, the call occurred time out, which means the waiting time for the connection to be established has expired. Some possible reasons are the database server is not running, or being but not accepting connections on port 1433 (have to see the configuration), the firewall may be blocking (unlikely in this case). Got to chase, more help than that would be technical support.

0

You have to enable TCP-IP and ips, add in the field in the port field tcp to port 1433inserir a descrição da imagem aqui

0

Iae Jader, all right?

Dude, I’ve set up this way and nothing. Even I tested with another bank and worked the connection.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.