use of org.talend.daikon.exception.ExceptionContext.ExceptionContextBuilder in project components by Talend.
the class SnowflakeRowWriter method validateResultSet.
private boolean validateResultSet() throws SQLException {
List<Field> fields = mainSchema.getFields();
ResultSetMetaData rsMetadata = rs.getMetaData();
if (CUD_RESULT_SET_COLUMN_NAMES.contains(rsMetadata.getColumnName(1))) {
return false;
}
if (fields.size() != rsMetadata.getColumnCount()) {
throw new ComponentException(new DefaultErrorCode(400, "errorMessage"), new ExceptionContextBuilder().put("errorMessage", I18N_MESSAGES.getMessage("error.resultSetMapping")).build());
}
int counter = 0;
for (int i = 0; i < rsMetadata.getColumnCount(); i++) {
String rsColumnName = rsMetadata.getColumnName(i + 1);
for (Field field : fields) {
if (rsColumnName.equalsIgnoreCase(field.name())) {
counter++;
}
}
}
if (counter != rsMetadata.getColumnCount()) {
throw new ComponentException(new DefaultErrorCode(400, "errorMessage"), new ExceptionContextBuilder().put("errorMessage", I18N_MESSAGES.getMessage("error.resultSetMapping")).build());
}
resultSetValidation = true;
return true;
}
Aggregations