If you use theTable.getColumn(name), this will throw AmbiguousColumnException for you, so you can get rid of this else if