I have made a simple java project in which I am attempting to connect to an SQL Server 2019 (Developer Edition) database. However, when I try to do so, I get a login authentication error.
This is my code for the project:
package javafxapplication12;
import java.net.URL;
import java.sql.*;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
/**
*
* @author param
*/
public class FXMLDocumentController implements Initializable {
Connection con;
@FXML
private Label label;
@FXML
private void handleButtonAction(ActionEvent event) {
label.setText("Hello World!");
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=Financials;user=dbo;password=;Trusted_Connection=False;MultipleActiveResultSets=True");
System.out.println("Connected to database !");
}
catch(Exception sqle) {
System.out.println("Sql Exception :"+sqle.getMessage());
label.setText("Failed");
}
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
However, when I compile this file, I am always getting this error:
Sql Exception :Login failed for user 'dbo'. ClientConnectionId:053ffe3f-aa4b-4c6b-86ee-df080cd91cf6
After reading for some time on Stack, I tried changing the hostname from localhost to myLaptopName, but I am still getting the same error, which leads me to believe that I am going wrong somewhere fundamentally.
Further, as suggested by some other users, I enabled SQL Server and Windows Authentication mode in Server Security settings, but even this didn't help resolve the error.
I am using JDK 1.8 with Netbeans 8.2 and mssql-jdbc-9.4.0.jre8.jar connector to connect to a MS SQL SERVER 2O19 database.
Also, I wanted to add that when I used this query SELECT HOST_NAME() in SSMS, I got the result myLaptopName. This is why I tried replacing localhost with myLaptopName.
Additional Information:
User name: dbo
Password: (no password)
myLaptopName refers to "LAPTOP-UQQOO5F7"
Database details:
SSMS Login Screen:
Update: I tried to change the database name in the link to something different, just to check if that is causing any errors. Inspite of purposefully entering a wrong DB name (eg. FinAANCNAials), I am getting the same error !


LAPTOP-UQQOO5F7(which I had written as laptop name in my question). I tried replacing local host with this, but it still gives the same error.password=""to my code ?