The column consumer_id may exist in the table, it doesn't exist in the result set. You have one column, with as value the maximum of all consumer_id values, but that column has no name. You need to either retrieve the value using its index (
rs.getInt(0)), or give the column in the result set a name:
select max(consumer_id) as consumer_id from db_consumer.
I'll move this
thread to our
JDBC forum.