0
votes
public class RDF2Connection {

     static Connection connection=null;
     final static String connectionUrl = "jdbc:sqlserver://DESKTOP-Q5K9FE6:1433;" +
             "databaseName=RDFDB;";
    public static Connection getRdf2Connected(){

            try {
                Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                connection = DriverManager.getConnection(connectionUrl, "sa", "root");
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            return connection;
        }

}

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host DESKTOP-Q5K9FE6, 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.SQLServerException.makeFromDriverError(SQLServerException.java:206) at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:257) at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2385) at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:567) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1955) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1616) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1447) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:788) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1187) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:247) at com.rdf2.databaseconnection.RDF2Connection.getRdf2Connected(RDF2Connection.java:22) at MainClass.main(MainClass.java:53) java.lang.NullPointerException at MainClass.main(MainClass.java:54)

Process finished with exit code 0

2
Possible duplicate with thisTuyenNTA
Check to see if the netbios name resolve to the server. Try use ipadress instead? Or that the Mssqlserver is running.Minh Kieu
Take a look at this. Have you added the dll?Marco Luzzara
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: Pretty clear.chrylis -cautiouslyoptimistic-

2 Answers

0
votes

Can you see if the SQL Server is only listening on an IPv6 port? If so you can use the following

System.setProperty("java.net.preferIPv6Addresses", "true"); 

That would be my only suggestion as far as code changes. Possibly try and use the IP as opposed to the name. If that doesn't work you need to go to your SQL Server and verify that it accepts TCP/IP connections, or check your local firewall settings. At that point the question would be more appropriate for server exchange.

0
votes

just make sure this the the correct port

this is the true answer Thanks.