org.sqlite.JDBC will not be found



I'm just trying to generate a connection to a SQLITE database. Here you will see the code:

private void getConnection() throws ClassNotFoundException, SQLException {
con = DriverManager.getConnection("jdbc:sqlite:SQLiteTest1.db");

When I run the application in InteliJ IDEA 2016.2.2 I will get always the ClassNotFoundException

java.lang.ClassNotFoundException: org.sqlite.JDBC
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(
    at com.linuxmaker.SQLiteTest.getConnection(
    at com.linuxmaker.SQLiteTest.displayUsers(
    at com.linuxmaker.App.main(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at com.intellij.rt.execution.application.AppMain.main(

I understand org.sqlite.JDBC will not be found, because it seems not to appear in the classpath of the project.
But I have insert sqlite-jdbc- over CTRL+ALT+SHIFT+S "Libraries":

<component name="libraryTable">
<library name="sqlite-jdbc-">
<root url="jar://$APPLICATION_HOME_DIR$/lib/sqlite-jdbc-!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/sqlite-jdbc-!/" />
In the left pane of the Editor where the tree of packages in my project are shown, I can see under "Libraries" the directory "org". In "org" I found "sqlite" and the Class JDBC. It is also installed.
But why "org.sqlite.JDBC" will not be found?
Can someone help me?



Comment actions Permalink

It looks like you have added the library to the project, but didn't add this library to the dependencies of the module:

Comment actions Permalink

Hello Serge,

I don't understand it. When I open the module "Modules" then I see on the right pane also sqlite-jdbc- included with the scope "compile".  Or should I add the sqlite-jdbc- file additonally on that pane?

Comment actions Permalink

Looks good, but I can't reproduce it with the same setup:

Maybe your .jar is invalid or is missing files (like it contains only sources, but no .class files).

Please try this sample project that I've prepared:

Comment actions Permalink

Thanks Serge,

for your file of demonstration. Unfortunally it crashs still again.

Here are my settings for module Uebungsprojekt:

And there are the settings for the included libraries:

There is some setting which could be wrong. But I don't know which and where.

Best regards 

Comment actions Permalink

Okay, I don't know why, but now it runs.

Thanks for your support!



Please sign in to leave a comment.