SQLite3使用

介绍
  轻量级内存数据库
  http://www.cnblogs.com/newstart/archive/2013/01/06/2847067.html

下载

  http://www.sqlite.org/download.html (如sqlite-tools-win32-x86-3120100.zip)
  https://bitbucket.org/xerial/sqlite-jdbc/downloads (Java JDBC Library)
查看环境变量
  .show
CREATE Database
  http://www.tutorialspoint.com/sqlite/sqlite_create_database.htm
查看Database
  .databases
数据类型
  http://www.runoob.com/sqlite/sqlite-data-types.html
CREATE Table
  http://www.runoob.com/sqlite/sqlite-create-table.html
  e.g.create table t1(id NUMERIC, name TEXT);
查看Table
  .tables
插入
  http://www.runoob.com/sqlite/sqlite-insert.html
  e.g.INSERT INTO t1 values(1,"a1");
查询
  e.g.select * from t1;
更新
  http://www.runoob.com/sqlite/sqlite-update.html
删除
  http://www.runoob.com/sqlite/sqlite-delete.html
删除表
  http://www.runoob.com/sqlite/sqlite-drop-table.html
退出
  .quit
不支持

  (1)分析函数如 ROW_NUMBER()
  (2)本地变量定义(http://stackoverflow.com/questions/7739444/declare-variable-in-sqlite-and-use-it)
  (3)http://www.sqlite.org/omitted.html
详细语法
  http://www.cnblogs.com/helloandroid/articles/2150272.html

Java实现

import java.sql.*;
import org.sqlite.JDBC;

public class SqliteConn {
	
	public Statement sqliteConn() {
		Class.forName("org.sqlite.JDBC");
		Connection conn = DriverManager.getConnection("jdbc:sqlite:zieckey.db");
		Statement stat = conn.createStatement();
		return stat;
	}
	
	public Statement sqliteClose(Connection conn) {
		conn.close();
	}
	
	public void create(Statement stat) {
		stat.executeUpdate( "create temp table tbl1(name varchar(20), salary int);" );
	}
	
	public void query(Statement stat) {
		ResultSet rs = stat.executeQuery("select * from tbl1;");
		while (rs.next()) {
            System.out.print("name = " + rs.getString("name") + " ");
        }
        rs.close();
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值