SQLException: No suitable driver found for org.sqlite.JDBC

I am trying to run a code, which connect to SQLite database, using an Ant builder. When connecting I recieve a "java.sql.SQLException: No suitable driver found for org.sqlite.JDBC".

I put jar-connecter into "lib" folder, but not sure if I correctly described it in build.xml. Can you please point me into error.

My ant build.xml file snippet:

<target name="copy-res" description="Copying resources">
    <copy todir="${classes.dir}">
        <fileset dir="${res.dir}"/>
    </copy>
</target>

<target name="build" depends="compile, copy-res" description="Build all samples"/>

<target name="run" depends="build" description="Runs sample">
    <java classname="ViewConsole" fork="true" classpathref="sqlite.classpath">
     <classpath>
      <pathelement path="${classes.dir}"/>
     </classpath>
    </java>
</target>

 <!-- sqlite driver directory -->
<path id="sqlite.classpath">
 <fileset dir="lib">
  <include name="sqlite-jdbc-3.15.1.jar"/>
 </fileset>
</path>

The way I trying to connect to database:

    private static final String JDBC_DRIVER = "org.sqlite.JDBC";
    Class.forName(JDBC_DRIVER);
    System.out.println("Connection to database...");
    con = DriverManager.getConnection(JDBC_DRIVER);
    System.out.println("Connection is ok")
Jon Skeet
people
quotationmark

You're passing an inappropriate value to DriverManager.getConnection. It's meant to be a JDBC URL - you're just passing in a class name.

The JDBC URL for SQLite would be something like

"jdbc:sqlite:/home/leo/work/mydatabase.db"

people

See more on this question at Stackoverflow