技术开发 频道

开源数据库:Berkeley DB和SQLite

    3. 应用JNI直接调用SQLite功能 

    下面这段代码演示如何应用JNI接口操作SQLite。可以看到Database类的exec()方法是执行SQL语句的关键:

Database db = new Database(); try { //打开数据库 db.open("c:tempmydata.slt", 0666); db.interrupt(); db.busy_timeout(1000); db.busy_handler(null); db.exec("create table account (name varchar(10),gale boolean)" ,result); db.exec("insert into account values('steve','m')", result); db.exec("select * from account",result); //关闭数据库 db.close(); } catch (Exception e) { e.printStackTrace(); }


0
相关文章