Hi to all! I have SQL Server Express, SQL Server Management Studio 2012. My PC Name is : "SaboorPC" and SQL Server instance name is also "SaboorPC". I am trying to connect my Netbeans to My SQL Server but it is not connecting and giving the following error:

"com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the host SABOORPC, named instance saboorpc failed. Error: "java.net.SocketTimeoutException: Receive timed out". Verify the server and instance names and check that no firewall is blocking UDP traffic to port 1434. For SQL Server 2005 or later, verify that the SQL Server Browser Service is running on the host."

My code and connection url is as follows:

DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());

        String url ="jdbc:sqlserver://SABOORPC\\SaboorPC;databaseName = SampleDB;integratedSecurity = true;" ;

        con = DriverManager.getConnection(url);

        if(con!=null){
            System.out.println("Connection established");
        }
        else{
            System.out.println("Connection failed");
        }

I am also pasting pictures of my pc name and SQL Server Name. Please guide me what I am doing wrong?

PCName.PNG

ServerName.PNG

Just a guess. The last time I did something like this I did not have to call out the SQL Server Instance name. SQL was just a port on a server so I just needed the name of the PC.

Now that means the DNS or hosts file MUST resolve that name.

Question to you: Do you know how to test the name resolution?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.