首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

创设通用的分组索引查询

2013-03-25 
创建通用的分组索引查询/*** 索引查询一条记录** @param tableName 表名* @param fields 待查询的字段* @p

创建通用的分组索引查询
/** * 索引查询一条记录 * * @param tableName 表名 * @param fields 待查询的字段 * @param row_in_table 从该行开始,取值[1,记录总长度],出界位置返回0长度List<Map>结果 * @return 返回List<Map>类型的结果 * @throws SQLException */ public Map indexByRow(String tableName, String[] fields, int row_in_table) throws SQLException { String key = db.getFields(tableName)[0]; if (db.getKeys(tableName).length > 0) { key = db.getKeys(tableName)[0]; } IndexNode nodes = _indexNodeOne(tableName, row_in_table); Field f = db.getField(tableName, key); String sql = "select " + tool.arryToString(fields, ",") + " from " + tableName + " where " + key + "=" + nodes.getFirstKeyValue(); if (f.getTypeClassName().equals("java.lang.String")) { sql = "select " + tool.arryToString(fields, ",") + " from " + tableName + " where " + key + " like '" + nodes.getFirstKeyValue() + "'"; } Map m = this.queryOne(sql); return m; }

热点排行