Atitit db query op shourt code lib list 数据库查询类库最佳实践
目录
Class.forName("org.sqlite.JDBC");
Connection c = DriverManager.getConnection("jdbc:sqlite:test.db");
Statement stmt = c.createStatement();
String sql2 = "drop TABLE sys_data ";
exeUpdateSafe(stmt, sql2);
sql2 = "CREATE TABLE sys_data (jsonfld json )";
exeUpdateSafe(stmt, sql2);
// insert into facts values(json_object("mascot", "Our mascot is a dolphin name
// sakila"));
//
String sql = "insert into sys_data values('{"id":"19", "name":"Lida"}');";
exeUpdateSafe(stmt, sql);
sql="SELECT json_extract(jsonfld,'$.name') as name1 FROM sys_data limit 1;" ;
System.out.println(sql);
QueryRunner run = new QueryRunner();
//maphandler scare_handler
List<Map<String, Object>> query = run.query(c,sql, new MapListHandler());
System.out.println(query);
// run.query(conn, sql, rsh)