TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: no further information... Asking for your kind assistance

Viewed 39

I am an Upcoming BSIT Freshman this Year, trying to explore database creation with the use of Java language. My first obstacle is the connection process.

I have already enabled Named Pipes and TCP/IP in the protocols for my instance server in Sql Server Configuration Manager. I have also checked if the port number is correct in the TCP/IP properties. If you have any idea for a solution, please advice me.

Image of SSCM

I can open this server in Microsoft SQL Server Management Studio (it doesn't have SQL Server Authentication, pls tell me if that matters)

Here's the connection code I'm using:

import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;

public class Connection 
{
    public static void main(String[] args) throws ClassNotFoundException, SQLException 
    {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");  
        String connectionUrl = "jdbc:sqlserver://localhost\\MSSQLSERVER;databaseName=Profiling;";  
        java.sql.Connection con = DriverManager.getConnection(connectionUrl); 
        JOptionPane.showMessageDialog(null, "Connection Sucess.");
    }
}

And here's the error messages:

Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: no further information. 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@11.2.0.jre18/com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:237)
at com.microsoft.sqlserver.jdbc@11.2.0.jre18/com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:288)
at com.microsoft.sqlserver.jdbc@11.2.0.jre18/com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2519)
at com.microsoft.sqlserver.jdbc@11.2.0.jre18/com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:777)
at com.microsoft.sqlserver.jdbc@11.2.0.jre18/com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:3300)
at com.microsoft.sqlserver.jdbc@11.2.0.jre18/com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2950)
at com.microsoft.sqlserver.jdbc@11.2.0.jre18/com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2790)
at com.microsoft.sqlserver.jdbc@11.2.0.jre18/com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1663)
at com.microsoft.sqlserver.jdbc@11.2.0.jre18/com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1064)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:683)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:253)
at Connection.main(Connection.java:11)

0 Answers
Related