cleanup of JDBC handling; added robustness against huge measurement hierarchies