0

I just created a SQLite database called database.db in IntelliJ. When I'm trying to connect my code to database, I get the following error

java.lang.ClassNotFoundException: org.sqlite.JDBC

I added JDBC manually to dependencies and the connection in database window is good. This is my code:

public static void connect() {
    Connection c = null;
    try {
        Class.forName("org.sqlite.JDBC");
        c = DriverManager.getConnection("jdbc:sqlite:database.db");
    } catch ( Exception e ) {
        System.err.println( e.getClass().getName() + ": " + e.getMessage() );
        System.exit(0);
    }
    System.out.println("Opened database successfully");
}
Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175
Crisiroid
  • 5
  • 5
  • It sounds like you only added the SQLite JDBC driver to the IntelliJ database configuration, not to the classpath (dependencies) of your Java application. – Mark Rotteveel May 09 '22 at 11:19

0 Answers0