Ejemplo n.º 1
0
  @Override
  public List<TableModel> getTablesByName(String tableName, PageBean pageBean) throws Exception {
    //		jdbcHelper.setCurrentDb(currentDb);
    //		jdbcHelper=JdbcHelper.getInstance();
    String sql = SQL_GET_ALL_TABLE_COMMENT;
    if (StringUtil.isNotEmpty(tableName))
      sql += " AND UPPER(TABNAME) LIKE '%" + tableName.toUpperCase() + "%'";

    List<TableModel> tableModels = getForList(sql, pageBean, tableModelRowMapper, SqlTypeConst.DB2);

    List<String> tableNames = new ArrayList<String>();
    // get all table names
    for (TableModel model : tableModels) {
      tableNames.add(model.getName());
    }
    // batch get table columns
    Map<String, List<ColumnModel>> tableColumnsMap = getColumnsByTableName(tableNames);
    // extract table columns from paraTypeMap by table name;
    for (Entry<String, List<ColumnModel>> entry : tableColumnsMap.entrySet()) {
      // set TableModel's columns
      for (TableModel model : tableModels) {
        if (model.getName().equalsIgnoreCase(entry.getKey())) {
          model.setColumnList(entry.getValue());
        }
      }
    }
    return tableModels;
  }
Ejemplo n.º 2
0
 @SuppressWarnings("unchecked")
 @Override
 public Map<String, String> getTablesByName(String tableName) {
   String sql = SQL_GET_ALL_TABLE_COMMENT;
   if (StringUtil.isNotEmpty(tableName))
     sql += " AND UPPER(TABNAME) LIKE UPPER('%" + tableName + "%')";
   //		jdbcHelper.setCurrentDb(currentDb);
   //		jdbcHelper=JdbcHelper.getInstance();
   Map<String, Object> parameter = new HashMap<String, Object>();
   List<Map<String, String>> list =
       JdbcTemplateUtil.getNamedParameterJdbcTemplate(jdbcTemplate)
           .query(sql, parameter, tableMapRowMapper);
   Map<String, String> map = new LinkedHashMap<String, String>();
   for (int i = 0; i < list.size(); i++) {
     Map<String, String> tmp = (Map<String, String>) list.get(i);
     String name = tmp.get("name");
     String comments = tmp.get("comments");
     map.put(name, comments);
   }
   return map;
 }