Good morning, everyone. I am developing a program to manage a database created in Mysql. My application is in java and to connect to the database at the moment I was using the driver manager of the mysql connector in an insecure way. Now that I have almost finished the program I would like to connect securely to the database via SSL if possible but I do not have much idea of what code I should integrate into my program to be able to do this. Here I leave the fragment of code that I am using to connect to the database. Thank you.
private void connection() {
try {
Class.forName("com.mysql.jdbc.Driver");
// connect way #1
//String url1 = "jdbc:mysql://localhost/usuarios";
String url1 = "jdbc:sqlserver://localhost;" +
"databaseName=name;integratedSecurity=true;";
String user = "******";
String password = "******";
connection = DriverManager.getConnection(url1, user, password);
if (connection != null) {
System.out.println("Connected to PRIVILEGES ACCESS");
conect = true;
}
} catch (SQLException ex) {
System.out.println("An error occurred. Maybe user/password is invalid");
ex.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}