Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

JAVA-java-lang-ClassNotFoundException-org-postgresql-Driver-Android

Asked by Kobayashi Sasaki Feb 8, 2021 1.4K views 1 answer
Share

About this question

I am running the Eclipse on the Windows operating system.

I downloaded JDBC4, added it to my build path using Project>Properties>add External JAR, browsed for the file, it worked (.classpath file shows the correct lib path).

The package shows in my Referenced Libraries folder, so I am continuing the tutorial.

import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;

    ....

    public void open ()
        {
    try {
        Class.forName("org.postgresql.Driver");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }

    try {
        conn = DriverManager.getConnection(url, username, password);
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

I think it would be as simple as that but I get hit with this big long stack trace starting with 

java.lang.ClassNotFoundException: org.postgresql.Driver

I tried include org.postgresql.*; but that didn't help either. I had also tried the JDBC3 but no luck there either. 

I'm very new to the Android, Postgresql and Web development, so a simple answer would be appreciated.

Your answer

1 Answer

More SQL Server discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest SQL Server Blogs

Guides, tips and career advice on SQL Server from JanBask experts.