I am trying to connect to my Postgresql database but when trying to connect to the driver I get an error message saying 'unable to load driver class!'. I don't understand why this is happening. Is there anything I've missed in the code I've written?
public class getDatabase {
private Connection conn;
private PreparedStatement getEmployees;
public getDatabase() {
try {
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", "postgres", "anna123");
}
catch(ClassNotFoundException ex) {
System.out.println("Error: unable to load driver class!");
System.exit(1);
} catch (SQLException e1) {
e1.printStackTrace();
} catch (Exception e2) {
e2.printStackTrace();
}
//Setting up the prepared SQL-queries we will need.
try {
getEmployees = conn.prepareStatement("SELECT * FROM employee");
} catch (SQLException e) {
System.out.println("Error: unable to prepare SQL statements.");
e.printStackTrace();
}
}