Hello, I have the following code
public class main {
private static Connection cn;
public static Connection getConexion() {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
cn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=Persona");
} catch (ClassNotFoundException | SQLException e) {
cn = null;
}
return cn;
}
public static void main(String[] args) {
//menuPrincipal mp = new menuPrincipal();
//mp.setVisible(true);
Connection prueba = main.getConexion();
if (prueba != null) {
System.out.println("Conexion realizada con exito...");
} else {
System.out.println("Error en la conexion...");
}
}
}
Which returns me "Error in the connection". I have managed to do the same through the "Services" panel as you can see below
But my method doesn't return what I'm looking for.
It is missing to add a properties in which the user and the access password are added