thanks for any help, I am a complete noob here but trying to learn. the below code is simply trying to create a connection to a database. I am getting this error back:
java.lang.ClassNotFoundException: org.postgres.Driver at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at CreateDB.main(CreateDB.java:11) java.lang.ClassNotFoundException: org.postgres.Driver
having researched online the solution i come across is to check the library is added to to build path. i can confirm that i have (I think). to do this i right clicked the prject -> Properties -> Java Build Path -> external JARS and navigated to the postgresql - 42.41.4..jar which is located in "...\eclipse-workspace\libraries\" I can see that the library is added under referenced libraries within the project. not a clue now im stuck. any help is genuinely appreciated.
I am learning from here https://www.tutorialspoint.com/postgresql/postgresql_java.htm
import java.sql.Connection;
import java.sql.DriverManager;
public class CreateDB {
public static void main(String Args[]) {
Connection c = null;
try {
Class.forName("org.postgres.Driver");
c = DriverManager.getConnection("jdbc.postgresql://localhost:1080/VEM", "postgres", "Diablo12" ); //creates connection with U&P
} catch (Exception e) {
e.printStackTrace();
System.err.println(e.getClass().getName() +": " + e.getMessage());
System.exit(0);
}
System.out.println("Database opened successfully");
}
}
Class.forName()is no longer needed since Java 6