SQLiteJDBC

100% Pure Java

A JDBC driver for SQLite. It comes in two flavours, a 100% Pure Java driver based on NestedVM or a native JNI library. The pure java driver is compatible, you can follow the Java dream and use it anywhere with no worries. The native driver is fast, and I recommend it wherever possible. Binaries are provided for Windows and Mac OS X.

News

  • 2008-05-11: Version v047 released: major internal work plugs a long standing memory leak.
  • 2008-04-17: Version v044 released: minor bug fixes and an upgrade to 3.5.8.
  • 2008-03-16: Version v043 released: support for multiple connections in the Pure Java version on Java 6.
  • 2008-03-05: Version v042 released: switch to using the amalgamation source, integrate FTS3 (full text search), and bring back the pure java builds.
  • 2008-03-05: Bring back the Linux binary.
  • 2008-03-03: Version v041 released: possible data corruption bug fix, details.

Getting Started

Read the usage page for some basic details. The short story is:

import java.sql.*;

public class Test {
    public static void main(String[] args) throws Exception {
        Class.forName("org.sqlite.JDBC");
        Connection conn = DriverManager.getConnection("jdbc:sqlite:test.db");
        Statement stat = conn.createStatement();
        stat.executeUpdate("drop table if exists people;");
        stat.executeUpdate("create table people (name, occupation);");
        PreparedStatement prep = conn.prepareStatement(
            "insert into people values (?, ?);");

        prep.setString(1, "Gandhi");
        prep.setString(2, "politics");
        prep.addBatch();
        prep.setString(1, "Turing");
        prep.setString(2, "computers");
        prep.addBatch();
        prep.setString(1, "Wittgenstein");
        prep.setString(2, "smartypants");
        prep.addBatch();

        conn.setAutoCommit(false);
        prep.executeBatch();
        conn.setAutoCommit(true);

        ResultSet rs = stat.executeQuery("select * from people;");
        while (rs.next()) {
            System.out.println("name = " + rs.getString("name"));
            System.out.println("job = " + rs.getString("occupation"));
        }
        rs.close();
        conn.close();
    }
}
Run with: java -cp .:sqlitejdbc-v047-native.jar -Djava.library.path=. Test

Getting Help

If you have any problems or questions, there is a public mailing list http://groups.google.com/group/sqlitejdbc which I read.

Keeping Informed

To be informed when a new release is made, I recommend subscribing to the freshmeat project for this driver. Every release I make goes up there immediately with a short summary of the changes. They provide a free email service with these details and don't load you up with spam.

Released under a BSD license.

Version control for this project is handled with darcs. You can access the darcs repo via either:
     http://www.zentus.com/sqlitejdbc/src
or
     /afs/hcoop.net/user/c/cr/crawshaw/web/zentus/sqlitejdbc/src

My other projects.

Current Version: v047 (SQLite 3.5.8)

Download

Documentation