private String updateSql(final String sql, HashMap<Integer, String> parameters) throws SQLException {
    List<String> parts = splitSqlStatement(sql);

    StringBuilder newSql = new StringBuilder(parts.get(0));
    for (int i = 1; i < parts.size(); i++) {
      if (!parameters.containsKey(i)) {
        throw new SQLException("Parameter #" + i + " is unset");
      }
      newSql.append(parameters.get(i));
      newSql.append(parts.get(i));
    }
    return newSql.toString();
  }
update the SQL string with parameters set by setXXX methods of {@link PreparedStatement}

@param sql
@param parameters
@return updated SQL string
@throws SQLException
jdbc/src/java/org/apache/hive/jdbc/HivePreparedStatement.java