Is it possible to check a ResultSet to see if it contains a column label for the current row. I would assume that it is backed by some kind of Map, so providing an rs.contains(“label”) method can’t be that expensive, but I can’t find one in the javadoc.
The current way I’m testing for the presence of a label is:
BigDecimal bid;
try {
bid = rs.getBigDecimal("bid");
}
catch(final SQLException e) {
bid = null;
}
But this seems untidy to me, and will be unreadable if you want to test multiple rows in this manner.
You can use metadata that you can obtain from resultset. Use
rs.getMetaData(), and then on metadata there aregetColumnName()andgetColumnLabel()methods.