Java.Lang.Classnotfoundexception: Org.Postgresql.Driver, Android

Driver JDBC PostgreSQL with Android

While not the strict answer to your question, I do have a suggestion.

Don't try to use JDBC on the Android device directly. You'll save a lot of hassle that way. I wrote about that in more detail on the "JDBC vs Web Service for Android" question.

Write your database logic on a web-accessible application server and talk to that application server via HTTP+JSON, SOAP, XML-RPC, or similar. This will be a lot more bandwidth efficient and you can make your app a lot more tolerant of issues with connectivity that way. It also saves you from having to expose your database server directly to the Internet - not much of a worry with PostgreSQL so long as you use SSL, but still better not to have to do at all.

Using JAX-RS on JBoss AS 7, Tomcat 7, or similar you should be able to put together a web RESTful XML/JSON services API for your app pretty easily. People also seem to put REST/JSON APIs together pretty quickly with PHP.

You can write a JSON/REST web API in pretty much any language you like with varying degrees of ease. Just search for REST server yourlanguagename.

"Kaw" has pointed out in a deleted answer that there are also virtual JDBC drivers that tunnel requests over HTTP. These may be suitable for some applications.

df.show returning java.lang.ClassNotFoundException: org.postgresql.Driver

I resolved this problem by adding the following parameters in the Zeppelin interpreter menu:

spark.driver.extraClassPath=/home/hadoop/postgresql-42.2.18.jar 
spark.jars.packages=org.postgresql:postgresql:42.2.18

Spring Data java configuration doesn't find the org.postgresql.Driver

In case you need any class from the Postgres JDBC jar, Modify your dependency to provided. If not just remove it.

   <!-- Postgres -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1205-jdbc42</version>
<scope>provided</scope>
</dependency>

And then add the Postgres JDBC jar to the lib path of tomcat

{tomcat7_home_path}/lib

java.lang.ClassNotFoundException: org.postgresql.Driver with Maven

With your pom.xml the following should work

  1. create the application

    mvn package
  2. run your application

    cd target/
    java -jar Monitoring-1.0-SNAPSHOT.jar

assuming Monitor.java as

public class Monitor {
public static void main(String[] args) throws Exception {
Class.forName("org.postgresql.Driver");
System.out.println("Hello driver");
}
}

the steps on top will print

Hello driver

To run your application all the jar files from target/*.jar must be in the same directory as the Monitoring-1.0-SNAPSHOT.jar.



Related Topics



Leave a reply



Submit