创建通用的分组索引查询
/** * 索引查询一条记录 * * @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; }