Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
java.lang.ClassNotFoundException: org.postgresql.Driver
Hello.
I have following error:
java.lang.ClassNotFoundException: org.postgresql.Driver
When tring to use SQLContainer with postgresql. Postgresql eclipce plugin is added to the project.
You are missing PostgreSQL JDBC driver jar in your project. Do you have a Maven project or what is your build method?
Johannes Häyry: You are missing PostgreSQL JDBC driver jar in your project. Do you have a Maven project or what is your build method?
Hello, I have add postgresql offical jar file into project through eclipse interface through java build path for project.
My build method is maven.
I also tried manualy put postgre*.jar into resource folder. In fact i managed to connect ot DB somehow, I think the problem was in the connection string. When i'll be near my IDE I'll post currecnt error.
Here is the error:
java.lang.ClassNotFoundException: org.postgresql.Driver
Screen of the imported library in eclipse is in the attachment.
The code:
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
//import org.postgresql.jdbc.Dr;
public class JDBCExample {
public static void init() {
System.out.println("-------- PostgreSQL "
+ "JDBC Connection Testing ------------");
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException e) {
System.out.println("Where is your PostgreSQL JDBC Driver? "
+ "Include in your library path!");
e.printStackTrace();
return;
}
System.out.println("PostgreSQL JDBC Driver Registered!");
Connection connection = null;
try {
connection = DriverManager.getConnection(
"jdbc:postgresql://5.189.246.141:5432/data_base_name", "postgres",
"postgres");
} catch (SQLException e) {
System.out.println("Connection Failed! Check output console");
e.printStackTrace();
return;
}
if (connection != null) {
System.out.println("You made it, take control your database now!");
} else {
System.out.println("Failed to make connection!");
}
}
}
-------- PostgreSQL JDBC Connection Testing ------------
Where is your PostgreSQL JDBC Driver? Include in your library path!
java.lang.ClassNotFoundException: org.postgresql.Driver
Can you help me with this?
Why don't you add a maven dependency on the driver? Like
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
for example.
Anyway, I'm not an eclipse expert, but you need the driver in the runtime classpath, I suspect that's the problem.
Eclipse has this run configuration thingy, I guess you need to add it there somewhere.