java.lang.ClassNotFoundException: org.postgresql.Driver, Android java.lang.ClassNotFoundException: org.postgresql.Driver, Android postgresql postgresql

java.lang.ClassNotFoundException: org.postgresql.Driver, Android


You need to add the PostgreSQL JDBC Driver in your project as mentioned in search.maven.org.

Gradle:

implementation 'org.postgresql:postgresql:42.2.10'

Maven:

<dependency>  <groupId>org.postgresql</groupId>  <artifactId>postgresql</artifactId>  <version>42.2.10</version></dependency>

You can also download the JAR and import to your project manually.

NOTE: Compile as used in this answer is deprecated. Replace with implementation as per 3.


You should put the jar package into the lib folder(WebContent-WEB-INF-lib),and right click on the jar package-build path-add to build path


It's a CLASSPATH issue; the PostgreSQL JDBC driver isn't available when the class loader tries to load it. You need to add it to your CLASSPATH correctly.

If it works in Eclipse, it's because adding a JAR to the build path is adding it to the CLASSPATH. You have to understand how CLASSPATH works without the Eclipse training wheels to help you.