pratnala pratnala - 10 days ago 7
Java Question

Tomcat cannot find the Postgres driver

I have a webapp in Tomcat which connects to a PostgreSQL database. I have included the JDBC PostgreSQL driver in the

lib/
folder of my webapp. The IDE I am using is Eclipse.

I get this error

java.lang.ClassNotFoundException: org.postgresql.driver


Relevant code snippet:

Class.forName("org.postgresql.driver");
String connectionUrlString = "jdbc:postgresql://server_addr:5432/db_name";
Connection dbConnection = null;
dbConnection = DriverManager.getConnection (connectionUrlString, username, password);

Answer

Try with a capital D:

Class.forName("org.postgresql.Driver");