Ejemplo n.º 1
0
  public DB2Manager() throws Exception {
    dbReader =
        DbReader.getInstance(
            Constants.JDBC_DRVER_DB2,
            Constants.JDBC_CONNECTION_URL,
            Constants.DB_USER,
            Constants.DB_PASS);

    configProp = PropertiesReader.loadPropertyFile(Constants.CONFIG_PROP_PATH);
    sqlPropFileName = configProp.getProperty(Constants.KEY_SQL_PROP_FILE);
  }
Ejemplo n.º 2
0
  /**
   * Executes all the SQL queries passed to it
   *
   * @param queries
   * @return List of HashMap containing all the query results where Keys are column names
   * @throws SQLException
   */
  public List<Map<String, String>> executeQueries(List<String> queries) throws SQLException {
    Iterator<String> queriesIt = queries.iterator();
    List<Map<String, String>> resultList = new ArrayList<Map<String, String>>();

    // Iterating through all the passed queries
    while (queriesIt.hasNext()) {
      String query = queriesIt.next();

      // Executing query
      List<Map<String, String>> results = dbReader.executeQuery(query);
      if (results != null) {
        resultList.addAll(results);
      }
    }
    logger.info(resultList.toString());
    return resultList;
  }