so I am writing a programm that accesses a database but whenever i can the method Class.forName("org.postgresql.Driver);
the ClassNotFoundException is thrown.
I have looked at every solution to this problem I could find, but nothing worked.
I hope you can help me with this.
Code:
public static void editDatabase(String[] values){
Connection connect = null;
Statement statement = null;
ResultSet result = null;
try {
Class.forName("org.postgresql.Driver");
connect = DriverManager.getConnection(values[0],values[1],values[2]);
statement = connect.createStatement();
result = statement.executeQuery("select * from Kunde");
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
This problem means that your project does not load 'org.postgresql.Driver' at init. If you are using IntelliJ, you must add org.postgresql.Driver using 'Project Structure', it's located at your top right window. If you're not using IDE, I do recommend you to use one.
You could also use Maven and add 'org.postgresql.Driver' as a requirement for your project.
Bye.