I'm trying to connect my sql database to my java project but for some reason the postgresql.Driver (org.postgresql.Driver) doesn't seem to work.
I've made sure to import all sql methods and such (java.sql.*)
the method i'm trying to run looks like this:
public boolean createUserInDB(String username, String password, boolean b, java.util.Date createdTime, java.util.Date lastLoginTime) {
try {
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection(url, username, password);
Statement st = conn.createStatement();
String sql = "INSERT INTO login(brugernavn, kodeord, status, created_time, last_login_time) "
+ "VALUES(" + username + ", " + password + ", " + true + ", "
+ createdTime + ", " + lastLoginTime + ");";
st.executeUpdate(sql);
System.out.println("Query successfull");
} catch (Exception e) {
System.out.println(e.getMessage());
}
return true;
}
Don't mind the first line of the query (the attributes are in danish).
When running this method the only thing it does is printing out "org.postgresql.Driver" and then returns true hence telling the user (in GUI) that the query has been made.
I've downloaded the newest driver for the postgresql version 42.2.2 but still no luck.
What am I missing?