本文翻译自:Java and SQLite [closed]
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. 什么驱动程序/连接器库可以连接并使用SQLite和Java。
I've discovered a wrapper library, http://www.ch-werner.de/javasqlite , but are there other more prominent projects available? 我发现了一个包装库, http://www.ch-werner.de/javasqlite ,但还有其他更突出的项目吗?
#1楼
参考:https://stackoom.com/question/Aj3/Java和SQLite-关闭
#2楼
David Crawshaw project(sqlitejdbc-v056.jar) seems out of date and last update was Jun 20, 2009, source here David Crawshaw项目(sqlitejdbc-v056.jar)似乎已过期,最后更新时间为2009年6月20日, 来源此处
I would recomend Xerials fork of Crawshaw sqlite wrapper. 我会推荐Crawshaw sqlite包装器的Xerials fork 。 I replaced sqlitejdbc-v056.jar with Xerials sqlite-jdbc-3.7.2.jar file without any problem. 我用Xerials sqlite-jdbc-3.7.2.jar文件替换了sqlitejdbc-v056.jar没有任何问题。
Uses same syntax as in Bernie's answer and is much faster and with latest sqlite library. 使用与Bernie的答案相同的语法,并且速度更快,并且使用最新的sqlite库。
What is different from Zentus's SQLite JDBC? 与Zentus的SQLite JDBC有什么不同?
The original Zentus's SQLite JDBC driver http://www.zentus.com/sqlitejdbc/ itself is an excellent utility for using SQLite databases from Java language, and our SQLiteJDBC library also relies on its implementation. 最初的Zentus的SQLite JDBC驱动程序http://www.zentus.com/sqlitejdbc/本身是使用Java语言的SQLite数据库的绝佳工具,我们的SQLiteJDBC库也依赖于它的实现。 However, its pure-java version, which totally translates c/c++ codes of SQLite into Java, is significantly slower compared to its native version, which uses SQLite binaries compiled for each OS (win, mac, linux). 但是,它的纯java版本完全将SQLite的c / c ++代码转换为Java,与其本机版本相比要慢得多,后者使用为每个操作系统编译的SQLite二进制文件(win,mac,linux)。
To use the native version of sqlite-jdbc, user had to set a path to the native codes (dll, jnilib, so files, which are JNDI C programs) by using command-line arguments, eg, -Djava.library.path=(path to the dll, jnilib, etc.), or -Dorg.sqlite.lib.path, etc. This process was error-prone and bothersome to tell every user to set these variables. 要使用sqlite-jdbc的本机版本,用户必须使用命令行参数设置本机代码(dll,jnilib,so文件,即JNDI C程序)的路径,例如-Djava.library.path = (dll,jnilib等的路径),或-Dorg.sqlite.lib.path等。这个过程容易出错,并且告诉每个用户设置这些变量很麻烦。 Our SQLiteJDBC library completely does away these inconveniences. 我们的SQLiteJDBC库完全消除了这些不便之处。
Another difference is that we are keeping this SQLiteJDBC libray up-to-date to the newest version of SQLite engine, because we are one of the hottest users of this library. 另一个区别是我们将这个SQLiteJDBC库保持最新版本的SQLite引擎,因为我们是这个库的最热门用户之一。 For example, SQLite JDBC is a core component of UTGB (University of Tokyo Genome Browser) Toolkit, which is our utility to create personalized genome browsers. 例如,SQLite JDBC是UTGB(东京大学基因组浏览器)工具包的核心组件,它是我们创建个性化基因组浏览器的实用工具。
EDIT : As usual when you update something, there will be problems in some obscure place in your code(happened to me). 编辑 :像往常一样,当你更新某些东西时,你的代码中会出现一些不明显的问题(发生在我身上)。 Test test test =) 测试测试=)
#3楼
There is a new project SQLJet that is a pure Java implementation of SQLite. 有一个新项目SQLJet是SQLite的纯Java实现。 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. 它还不支持所有SQLite功能,但对于一些使用SQLite数据库的Java项目来说可能是一个非常好的选择。
#4楼
sqlitejdbc code can be downloaded using git from https://github.com/crawshaw/sqlitejdbc . 可以使用https://github.com/crawshaw/sqlitejdbc中的 git下载sqlitejdbc代码。
# git clone https://github.com/crawshaw/sqlitejdbc.git sqlitejdbc
...
# cd sqlitejdbc
# make
Note: Makefile requires curl binary to download sqlite libraries/deps. 注意:Makefile需要curl二进制文件来下载sqlite库/ deps。
#5楼
The wiki lists some more wrappers: 维基列出了一些包装器:
- Java wrapper (around a SWIG interface): http://tk-software.home.comcast.net/ Java包装器(围绕SWIG接口): http : //tk-software.home.comcast.net/
- A good tutorial to use JDBC driver for SQLite. 为SQLite使用JDBC驱动程序的好教程。 (it works at least !) http://www.ci.uchicago.edu/wiki/bin/view/VDS/VDSDevelopment/UsingSQLite (它至少起作用!) http://www.ci.uchicago.edu/wiki/bin/view/VDS/VDSDevelopment/UsingSQLite
- 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: https://github.com/xerial/sqlite-jdbc (formerly zentus ) 跨平台JDBC驱动程序,它在Windows,Linux,OS X上使用嵌入式本机SQLite库,并回退到其他操作系统上的纯Java实现: https : //github.com/xerial/sqlite-jdbc (以前的zentus )
- Another Java - SWIG wrapper. 另一个Java - SWIG包装器。 It only works on Win32. 它只适用于Win32。 http://rodolfo_3.tripod.com/index.html http://rodolfo_3.tripod.com/index.html
- sqlite-java-shell: 100% pure Java port of the sqlite3 commandline shell built with NestedVM. sqlite-java-shell:使用NestedVM构建的sqlite3命令行shell的100%纯Java端口。 (This is not a JDBC driver). (这不是JDBC驱动程序)。
- SQLite JDBC Driver for Mysaifu JVM: SQLite JDBC Driver for Mysaifu JVM and SQLite JNI Library for Windows (x86) and Linux (i386/PowerPC). 用于Mysaifu JVM的SQLite JDBC驱动程序:用于Mysaifu JVM的SQLite JDBC驱动程序和用于Windows(x86)和Linux(i386 / PowerPC)的SQLite JNI库。
#6楼
Bernie's post is very helpful. 伯尼的帖子非常有帮助。 Couldn't vote up (don't have enough reputation :( ). But it Helped a lot. Just to reiterate! 无法投票(没有足够的声誉:()。但它帮了很多。重申一下!
http://www.zentus.com/sqlitejdbc/ http://www.zentus.com/sqlitejdbc/
Here you can find the latest SQLite JDBC jar. 在这里,您可以找到最新的SQLite JDBC jar。 Just add the jar into you classpath and you are done! 只需将jar添加到classpath中即可完成! :) You can run Bernie's sample code to test if everything is fine. :)您可以运行Bernie的示例代码来测试一切是否正常。
http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html http://www.sqlite.org/lang.html http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html http://www.sqlite.org/lang.html
Here you can find some help on SQL syntax for SQLite. 在这里,您可以找到有关SQLite的SQL语法的一些帮助。 Cheers to SQLite :) 欢呼来到SQLite :)