Datenbank Zugraff nach Umwandlung in .jar-Datei nicht mehr möglich

MJannek

Bekanntes Mitglied
Ich habe in Java ein Programm geschrieben, über das ich auf eine MySQL DB zugreife. Wenn ich das Programm aus IntelliJ starte, funktioniert alles, nachdem ich mein Passwort eingegeben habe. Führe ich allerdings die dazugehörige .jar-Datei Datei aus, kommt sofort die Fehlermeldung "No suitable driver found".
Wo ist mein Fehler.
LG Markus
 
Da fehlt entweder die Abhängigkeit (der jdbc Treiber) komplett oder der Service Eintrag ist nicht richtig übernommen worden. Aber ohne Details, wie Du z.B. das JAR File baust, kann man dazu nicht viel mehr sagen.
 
Um die jar zu bauen klicke ich in IntelliJ auf Build>Build Artifacts>Build
Nur leider besagt das nicht viel, denn ohne Details der Konfiguration dahinter wird man da weiter nichts sagen können.

Daher ist meine Empfehlung, möglichst schnell komplett auf Maven oder Gradle zu setzen. Dann liegt die Konfiguration des Projekts sauber in Textdateien vor und kann leicht geteilt werden.
 
Well, this error happens when JRE (which stands for Java Runtime Environment) cannot find the JBDC driver for MySQL. Well, below steps can help you fix this problem.
1. You need to be sure that your MySQL JDBC driver version matches the version of MySQL that you are using.
2. You also need to ensure that you have entered the correct username and password for your MySQL database.
3. You need to make sure that you have the necessary SSL certificates installed and configured.
4. You need to check that your program is using the correct driver class name when loading the JDBC driver.
Sorry - when the driver is missing, then
  • Username / password
  • SSL certificate
have nothing to do with the problem at all.

And regarding the driver class name: That is outdated! You do not have to give a class name of the driver since JDBC is using the service loader to load the correct driver automatically!
 

Neue Themen


Zurück
Oben