in java/clickhouse-client/src/main/java/com/epam/deltix/clickhouse/util/SelectQueryHelper.java [115:156]
public static <TEntry> List<TEntry> executeQuery(String sql, ClickhouseClient clickhouseClient,
List<SelectParam> params, RowMapper<TEntry> rowMapper) {
return ErrorHelper.handleClickhouseException(() -> {
if (LOG.isDebugEnabled()) {
LogEntry logEntry = LOG.debug()
.append("Prepared SQL: [")
.append(sql);
if (params != null)
logEntry = logEntry
.append("] (")
.append(params.stream().map(SelectParam::getValue).collect(Collectors.toList()))
.append(")");
logEntry.commit();
}
List<TEntry> entries = new ArrayList<>();
PreparedStatement ps;
try {
Connection connection = clickhouseClient.getConnection();
ps = connection.prepareStatement(sql);
buildPrepareStatement(params, ps);
ResultSet resultSet = ps.executeQuery();
int row = 0;
while (resultSet.next()) {
entries.add(rowMapper.mapRow(resultSet, ++row));
}
} catch (SQLException e) {
LOG.error()
.append("SQL error. ")
.append(e)
.commit();
throw e;
}
return entries;
}
);
}