0

I'm trying to connect to my database made on SSMS (Microsoft SQL Server Management Studio 18) using Java.

What I've attempted so far:

  • I have downloaded SSMS.
  • Added JDBC Driver dependency to pom.xml
  • Created a database, table, and queried data.

Snippet of my code:

public static void main(String[] args) throws SQLException {
    String dbUrl = "jdbc:sqlserver://localhost;databaseName=TutorialDB;integratedSecurity=true;";
    Connection connection = DriverManager.getConnection(dbUrl);
}

Error message:

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."

My database:
database information

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
noodles888
  • 31
  • 5
  • check the port is open... telnet localhost 1433 – Michael Wiles Nov 06 '21 at 11:17
  • @MichaelWiles How do I navigate and open the port? I'm sorry I'm a complete noob in databases. – noodles888 Nov 06 '21 at 11:17
  • try some ports, from command line type telnet localhost 1433, try some others that you know are open... like telnet google.com 80 (open port) and telnet google.com 81 (closed port) and compare what you get with the results from telnet localhost 1433 (this has nothing to do with databases btw) – Michael Wiles Nov 09 '21 at 07:47

0 Answers0