<p>I'm attracted to the neatness that a single file database provides. What driver/connector library is out there to connect and use SQLite with Java.</p>

<p>I've discovered a wrapper library, <a href="http://www.ch-werner.de/javasqlite/" rel="noreferrer">http://www.ch-werner.de/javasqlite</a>, but are there other more prominent projects available?</p>

[{'answer_id': 41241, 'author': 'Peter Hoffmann', 'author_id': 720, 'author_profile': 'https://Stackoverflow.com/users/720', 'pm_score': 9, 'selected': True, 'text': '<p>The <a href="http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers" rel="noreferrer">wiki</a> lists some more wrappers:</p>\n\n<ul>\n<li>Java wrapper (around a SWIG interface): <a href="http://tk-software.home.comcast.net/" rel="noreferrer">http://tk-software.home.comcast.net/</a></li>\n<li>A good tutorial to use JDBC driver for SQLite. (it works at least !) <a href="http://www.ci.uchicago.edu/wiki/bin/view/VDS/VDSDevelopment/UsingSQLite" rel="noreferrer">http://www.ci.uchicago.edu/wiki/bin/view/VDS/VDSDevelopment/UsingSQLite</a></li>\n<li>Cross-platform JDBC driver which uses embedded native SQLite libraries on Windows, Linux, OS X, and falls back to pure Java implementation on other OSes: <a href="https://github.com/xerial/sqlite-jdbc" rel="noreferrer">https://github.com/xerial/sqlite-jdbc</a> (formerly <a href="http://www.zentus.com/sqlitejdbc" rel="noreferrer">zentus</a>)</li>\n<li>Another Java - SWIG wrapper. It only works on Win32. <a href="http://rodolfo_3.tripod.com/index.html" rel="noreferrer">http://rodolfo_3.tripod.com/index.html</a></li>\n<li>sqlite-java-shell: 100% pure Java port of the sqlite3 commandline shell built with NestedVM. (This is not a JDBC driver).</li>\n<li>SQLite JDBC Driver for Mysaifu JVM: SQLite JDBC Driver for Mysaifu JVM and SQLite JNI Library for Windows (x86) and Linux (i386/PowerPC). </li>\n</ul>\n'}, {'answer_id': 593137, 'author': 'Bernie Perez', 'author_id': 1992, 'author_profile': 'https://Stackoverflow.com/users/1992', 'pm_score': 8, 'selected': False, 'text': '<p>I found your question while searching for information with <a href="http://www.sqlite.org/" rel="noreferrer">SQLite</a> and Java. Just thought I\'d add my answer which I also posted on my <a href="http://blog.rungeek.com/post/81611917/how-to-use-sqlite-with-java" rel="noreferrer">blog</a>.</p>\n\n<p>I have been coding in Java for a while now. I have also known about SQLite but never used it… Well I have used it through other <a href="http://www.sqlite.org/famous.html" rel="noreferrer">applications</a> but never in an app that I coded. So I needed it for a project this week and it\'s so simple use!</p>\n\n<p>I found a Java JDBC driver for SQLite. Just add the <a href="https://github.com/xerial/sqlite-jdbc" rel="noreferrer">JAR file</a> to your classpath and import java.sql.*</p>\n\n<p>His test app will create a database file, send some SQL commands to create a table, store some data in the table, and read it back and display on console. It will create the <strong>test.db</strong> file in the root directory of the project.  You can run this example with <code>java -cp .:sqlitejdbc-v056.jar Test</code>.</p>\n\n<pre><code>package com.rungeek.sqlite;\n\nimport java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.PreparedStatement;\nimport java.sql.ResultSet;\nimport java.sql.Statement;\n\npublic class Test {\n    public static void main(String[] args) throws Exception {\n        Class.forName("org.sqlite.JDBC");\n        Connection conn = DriverManager.getConnection("jdbc:sqlite:test.db");\n        Statement stat = conn.createStatement();\n        stat.executeUpdate("drop table if exists people;");\n        stat.executeUpdate("create table people (name, occupation);");\n        PreparedStatement prep = conn.prepareStatement(\n            "insert into people values (?, ?);");\n\n        prep.setString(1, "Gandhi");\n        prep.setString(2, "politics");\n        prep.addBatch();\n        prep.setString(1, "Turing");\n        prep.setString(2, "computers");\n        prep.addBatch();\n        prep.setString(1, "Wittgenstein");\n        prep.setString(2, "smartypants");\n        prep.addBatch();\n\n        conn.setAutoCommit(false);\n        prep.executeBatch();\n        conn.setAutoCommit(true);\n\n        ResultSet rs = stat.executeQuery("select * from people;");\n        while (rs.next()) {\n            System.out.println("name = " + rs.getString("name"));\n            System.out.println("job = " + rs.getString("occupation"));\n        }\n        rs.close();\n        conn.close();\n    }\n  }\n</code></pre>\n'}, {'answer_id': 594511, 'author': 'javashlook', 'author_id': 24815, 'author_profile': 'https://Stackoverflow.com/users/24815', 'pm_score': 5, 'selected': False, 'text': '<p>I understand you asked specifically about SQLite, but maybe <a href="http://hsqldb.org/" rel="noreferrer">HSQL database</a> would be a better fit with Java. It is written in Java itself, runs in the JVM, supports in-memory tables etc. and all that features make it quite usable for prototyping and unit-testing.</p>\n'}, {'answer_id': 1257831, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 4, 'selected': False, 'text': '<p>There is a new project <a href="http://sqljet.com/" rel="noreferrer" title="SQLJet">SQLJet</a> that is a pure Java implementation of SQLite. It doesn\'t support all of the SQLite features yet, but may be a very good option for some of the Java projects that work with SQLite databases.</p>\n'}, {'answer_id': 8797310, 'author': 'snail', 'author_id': 1139901, 'author_profile': 'https://Stackoverflow.com/users/1139901', 'pm_score': 2, 'selected': False, 'text': '<p>The example code leads to a memory leak in Tomcat (after undeploying the webapp, the classloader still remains in memory) which will cause an <code>outofmemory</code> eventually. The way to solve it is to use the <a href="http://www.xerial.org/maven/repository/snapshot/org/xerial/sqlite-jdbc/3.7.8-SNAPSHOT/" rel="nofollow">sqlite-jdbc-3.7.8.jar</a>; it\'s a snapshot, so it doesn\'t appear for maven yet.</p>\n'}, {'answer_id': 9046459, 'author': 'Eddie', 'author_id': 1175379, 'author_profile': 'https://Stackoverflow.com/users/1175379', 'pm_score': 0, 'selected': False, 'text': '<p>Typo: <code>java -cp .:sqlitejdbc-v056.jar Test</code></p>\n\n<p>should be: <code>java -cp .:sqlitejdbc-v056.jar; Test</code></p>\n\n<p>notice the semicolon after ".jar" i hope that helps people, could cause a lot of hassle </p>\n'}, {'answer_id': 9426806, 'author': 'aboutstudy', 'author_id': 1122995, 'author_profile': 'https://Stackoverflow.com/users/1122995', 'pm_score': 2, 'selected': False, 'text': '<p>When you compile and run the code, you should set the classpath options value.\nJust like the following:</p>\n\n<pre><code>javac -classpath .;sqlitejdbc-v056.jar Text.java\n\njava -classpath .;sqlitejdbc-v056.jar Text\n</code></pre>\n\n<p>Please pay attention to "." and the sparate ";"(win, the linux is ":")</p>\n'}, {'answer_id': 12278261, 'author': 'Daniel  Magnusson', 'author_id': 63678, 'author_profile': 'https://Stackoverflow.com/users/63678', 'pm_score': 4, 'selected': False, 'text': '<p>David Crawshaw project(sqlitejdbc-v056.jar) seems out of date and last update was Jun 20, 2009,  <a href="https://github.com/crawshaw/sqlitejdbc" rel="nofollow noreferrer">source here</a></p>\n\n<p>I would recomend <a href="http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC" rel="nofollow noreferrer">Xerials fork</a> of Crawshaw sqlite wrapper.  I replaced sqlitejdbc-v056.jar  with Xerials sqlite-jdbc-3.7.2.jar file without any problem. </p>\n\n<p>Uses same syntax as in <a href="https://stackoverflow.com/a/593137/63678">Bernie\'s answer</a> and is much faster and with latest sqlite library.</p>\n\n<p><strong>What is different from Zentus\'s SQLite JDBC?</strong></p>\n\n<blockquote>\n  <p>The original Zentus\'s SQLite JDBC driver\n  <a href="http://www.zentus.com/sqlitejdbc/" rel="nofollow noreferrer">http://www.zentus.com/sqlitejdbc/</a> itself is an excellent utility for\n  using SQLite databases from Java language, and our SQLiteJDBC library\n  also relies on its implementation. However, its pure-java version,\n  which totally translates c/c++ codes of SQLite into Java, is\n  significantly slower compared to its native version, which uses SQLite\n  binaries compiled for each OS (win, mac, linux).</p>\n  \n  <p>To use the native version of sqlite-jdbc, user had to set a path to\n  the native codes (dll, jnilib, so files, which are JNDI C programs) by\n  using command-line arguments, e.g., -Djava.library.path=(path to the\n  dll, jnilib, etc.), or -Dorg.sqlite.lib.path, etc. This process was\n  error-prone and bothersome to tell every user to set these variables.\n  Our SQLiteJDBC library completely does away these inconveniences.</p>\n  \n  <p>Another difference is that we are keeping this SQLiteJDBC libray\n  up-to-date to the newest version of SQLite engine, because we are one\n  of the hottest users of this library. For example, SQLite JDBC is a\n  core component of UTGB (University of Tokyo Genome Browser) Toolkit,\n  which is our utility to create personalized genome browsers.</p>\n</blockquote>\n\n<p><strong>EDIT</strong> : As usual when you update something, there will be problems in some obscure place in your code(happened to me). Test test test =)</p>\n'}, {'answer_id': 13273626, 'author': 'Morbo', 'author_id': 1806702, 'author_profile': 'https://Stackoverflow.com/users/1806702', 'pm_score': 2, 'selected': False, 'text': '<p>sqlitejdbc code can be downloaded using git from <a href="https://github.com/crawshaw/sqlitejdbc" rel="nofollow">https://github.com/crawshaw/sqlitejdbc</a>. </p>\n\n<pre><code># git clone https://github.com/crawshaw/sqlitejdbc.git sqlitejdbc\n...\n# cd sqlitejdbc\n# make\n</code></pre>\n\n<p>Note: Makefile requires curl binary to download sqlite libraries/deps.</p>\n'}]
['https://Stackoverflow.com/questions/41233', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1915/']