linux上 java 使用 javasqlite
http://www.ch-werner.de/javasqlite/
1) 下载:
http://www.ch-werner.de/javasqlite/javasqlite-20140624.tar.gz
2) 解压后进入目录编译
$ cd javasqlite-20140624
$ ./configure
$ make
3) 拷贝libsqlite_jni.so到/usr/lib64目录
$ sudo cp .libs/libsqlite_jni.so /usr/lib64
如果上一步不执行,会报错误:
Unable to load sqlite_jni: java.lang.UnsatisfiedLinkError: no sqlite_jni in java.library.path
4) 导入sqlite.jar到java项目中
5) 使用sqlite java wrapper:
import SQLite.Database;
...
Database db = new Dababase();
db.open(dbFile, SQLite.Constants.SQLITE_OPEN_READWRITE |
SQLite.Constants.SQLITE_OPEN_CREATE |
SQLite.Constants.SQLITE_OPEN_FULLMUTEX);
db.exec("create table ...", null);
打开sqlite db参考: