I know there are tons of similar questions that have been answered, but I've searched pretty much all of them and can't figure out the solution to my issue.
I am trying to connect to my SQL database with the below code, but I am getting an error. Before I show my code, I am able to connect to the same database using DBeaver
with the below connection details:
I am trying to connect to the database by doing:
Connection connection = DriverManager
.getConnection("jdbc:mysql://localhost:1433/master", "sa", "MY_PASSWORD_HERE");
However, at this point, my code doesn't throw any error, but it throws the below error after about 2 minutes, which I assume it has basically given up and timed out.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
I have no idea what I'm doing wrong as I've followed the same procedures as the countless tutorials online. Any help is appreciated.
For reference, I am building my project with Maven. Here is a snippet of the pom.xml
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
EDIT: running SELECT @@VERSION
returns:
Microsoft SQL Server 2019 (RTM-CU4) (KB4548597) - 15.0.4033.1 (X64)
Mar 14 2020 16:10:35
Copyright (C) 2019 Microsoft Corporation
Developer Edition (64-bit) on Linux (Ubuntu 18.04.4 LTS) <X64>
1 row(s) returned
Executed in 1 ms