Code: Select all
private static Connection getConnection(){
try {
return DriverManager.getConnection(
"jdbc:mysql://" + DB_HOST + ":" + DB_PORT + "/" + DB_NAME,
DB_USER,
DB_PASS
);
} catch (SQLException e) {
if (e instanceof CommunicationsException){
new Thread(() -> {
ProcessBuilder pb = new ProcessBuilder("net", "start", "mysql80")
.inheritIO();
try {
pb.start();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}).start();
try {
return DriverManager.getConnection(
"jdbc:mysql://" + DB_HOST + ":" + DB_PORT + "/" + DB_NAME,
DB_USER,
DB_PASS
);
} catch (SQLException ex) {
throw new RuntimeException(ex);
}
} else {
throw new RuntimeException(e);
}
}
}
Access denied.
< /code>
Dies liegt daran, dass ich Admin -Berechtigungen benötige, aber ich weiß nicht, wie ich das meiner Serverklasse geben soll oder wenn es eine gute Praxis ist. Ich bin in Windows 10 und arbeite an dem Projekt, also führe ich die Dateien über IDE (Intellij) aus.>