So I'm developing a database project in which I created my database, filled it with my tables, and am now starting to program a Java application to demonstrate it.
Now comes the problem: I don't stop getting the "java.lang.ClassNotFoundException: org.postgresql.Driver" gigantic error prompt or the "No suitable driver found for jdbc:postgresql://localhost:5432/project" prompt.
//File: Model.java
import java.sql.*;
class Model {
private final String url = "jdbc:postgresql://localhost:5432/Trabalho";
private final String usr = "postgres";
private final String pwd = "K1dN@m3dF1ng3r";
public Model() {
try {
Class.forName("org.postgresql.Driver");
} catch(ClassNotFoundException ex) {
ex.printStackTrace();
}
}
protected Connection connect() {
Connection con = null;
try {
con = DriverManager.getConnection(url,usr,pwd);
System.out.println("Connected to the PostgreSQL server successfully!");
} catch(SQLException ex) {
System.out.println(ex.getMessage());
}
return con;
}
}
//File: Control.java
class Control extends Model {
public Control() {
super.connect();
}
public static void main(String tx[]) {
new Control();
}
}
I have tried downloading the driver, searching for my lib folder, altering my classpath environment variable, I've checked PGAdmin, java, javac and the driver's versions, but nothing seems to work.
Also, most of the Qs/As here (all that I've found) seem to focus on Java IDEs that I don't use. I'm using VS Code, with its 0.25.11 Extension Pack for Java.