SQLiteJDBC
SQLiteJDBC is a Java JDBC driver for SQLite. It runs using either a native code library 100% Pure Java driver based on
NestedVM emulation.
Both the pure driver and the native binaries for Windows, Mac OS X, and Linux x86 have been combined into a single jar file.
Download
The current version is
v053, based on SQLite 3.6.1. All files can be found at the
download site.
sqlitejdbc-v053.jar - pure Java, containing binaries for Windows, Linux x86/amd64, and Mac OS X.
sqlitejdbc-v053-pure.jar - just the pure Java driver, always works, slowly.
sqlitejdbc-v053-bin.tgz - separate native binaries and a thin jar file.
sqlitejdbc-v053-src.tgz - source bundle.
-
News
2008-08-13: v053
Upgrade to SQLite 3.6.1 and add a native linux amd64 binary to the combined jar.
2008-06-28: v052
Closing a closed statement now has no effect, and among other bug fixes, binary size has shrunk, and whether the amalgamated jar is running in pure or native mode can be determined by DatabaseMetaData.getDriverVersion().
2008-06-17
Move to the new self-contained jar format with v050.
2008-06-13 Switch web site to
2008-05-30
Version v048 released: support for shared cache, upgrade to 3.5.9.
2008-05-11
Version v047 released: major internal work plugs a long standing memory leak.
Getting Started
Read the
usage page for the full story.
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-v053.jar Test
Getting Help
If you have any problems or questions, there is a public
mailing list which I read. To subscribe, send a message to sqlitejdbc-subscribe@googlegroups.com.
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 git. The repo can be found: