Saturday, April 9, 2022

[SOLVED] Popular error - org.sqlite.JDBC

Issue

package aplikacjajava;

import java.sql.*;

public class main
{
  public main( String args[] )
  {
    Connection c = null;
    try {
      Class.forName("org.sqlite.JDBC");
      c = DriverManager.getConnection("jdbc:sqlite:projekt.db");
    } catch ( Exception e ) {
      System.err.println( e.getClass().getName() + ": " + e.getMessage() );
      System.exit(0);
    }
    System.out.println("Opened database successfully");
  }
}

Error:

java.lang.ClassNotFoundException: org.sqlite.JDBC

I know that I'm missing JDBC driver. How to install it on Fedora?

I don't how to add some "path" and what is this at all. I need something like step-by-step explanation... This is first time when I met with such a problem.


Solution

  1. Download the SQLite-jar at http://search.maven.org/remotecontent?filepath=org/xerial/sqlite-jdbc/3.8.10.1/sqlite-jdbc-3.8.10.1.jar
  2. Add the jar file to your class path (open Eclipse project properties, there you'll find the build path)
  3. Run your program.

You usually use Maven, Gradle or manual dependency management when using Java. Linux package managers are very limited in java support.



Answered By - mp911de
Answer Checked By - Marilyn (WPSolving Volunteer)