Browse Source

Proper exception handling when user uses column name that does not appear in logical table

Christophe Debruyne 7 years ago
parent
commit
5587e04843
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/r2rml/database/Row.java

+ 5 - 1
src/r2rml/database/Row.java

@@ -25,7 +25,11 @@ public class Row {
 
 	public Object getObject(String column) throws R2RMLException {
 		try {
-			return resultset.getObject(indexMap.get(column));
+			Integer index = indexMap.get(column);
+			// Check whether the user added the right column names in the mappings
+			if(index == null)
+				throw new R2RMLException("Column '" +  column + "' does not exit in the logical table.", null);
+			return resultset.getObject(index);
 		} catch (SQLException e) {
 			throw new R2RMLException(e.getMessage(), e);
 		}