Beispiel #1
0
 @SuppressWarnings("unchecked")
 @Override
 public Map<String, String> getTablesByName(List<String> tableNames) {
   Map<String, String> map = new HashMap<String, String>();
   String sql = SQL_GET_ALL_TABLE_COMMENT;
   if (tableNames == null || tableNames.size() == 0) {
     return map;
   } else {
     StringBuffer buf = new StringBuffer();
     for (String str : tableNames) {
       buf.append("'" + str + "',");
     }
     buf.deleteCharAt(buf.length() - 1);
     sql += " AND UPPER(TABNAME) IN (" + buf.toString().toUpperCase() + ") ";
   }
   //		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);
   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;
 }
Beispiel #2
0
 /**
  * 根据表名,取得列模型列表。此处对表名进行非模糊匹配。 此方法使用批量查询方式。
  *
  * @param tableNames 表名列表。
  * @return Map,key=<table_name>,value=<List<columnModel>>
  */
 @SuppressWarnings("unchecked")
 private Map<String, List<ColumnModel>> getColumnsByTableName(List<String> tableNames) {
   String sql = SQL_GET_COLUMNS_BATCH;
   Map<String, List<ColumnModel>> map = new HashMap<String, List<ColumnModel>>();
   if (tableNames != null && tableNames.size() == 0) {
     return map;
   } else {
     StringBuffer buf = new StringBuffer();
     for (String str : tableNames) {
       buf.append("'" + str + "',");
     }
     buf.deleteCharAt(buf.length() - 1);
     sql += " AND UPPER(TABNAME) IN (" + buf.toString().toUpperCase() + ") ";
   }
   //		jdbcHelper.setCurrentDb(currentDb);
   //		jdbcHelper=JdbcHelper.getInstance();
   List<ColumnModel> columnModels =
       JdbcTemplateUtil.getNamedParameterJdbcTemplate(jdbcTemplate)
           .query(sql, new HashMap<String, Object>(), new DB2ColumnMap());
   for (ColumnModel columnModel : columnModels) {
     String tableName = columnModel.getTableName();
     if (map.containsKey(tableName)) {
       map.get(tableName).add(columnModel);
     } else {
       List<ColumnModel> cols = new ArrayList<ColumnModel>();
       cols.add(columnModel);
       map.put(tableName, cols);
     }
   }
   return map;
 }
Beispiel #3
0
 /**
  * 根据表名,取得列模型列表。此处对表名进行非模糊匹配。
  *
  * @param tableName 表名
  * @return 列模型列表
  */
 @SuppressWarnings("unchecked")
 private List<ColumnModel> getColumnsByTableName(String tableName) {
   String sql = String.format(SQL_GET_COLUMNS, tableName);
   //		jdbcHelper.setCurrentDb(currentDb);
   Map<String, Object> map = new HashMap<String, Object>();
   List<ColumnModel> list =
       JdbcTemplateUtil.getNamedParameterJdbcTemplate(jdbcTemplate)
           .query(sql, map, new DB2ColumnMap());
   return list;
 }
Beispiel #4
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;
 }