DB health check from application

Wrote method to established connection with database and tried to get metrics name to .metrics … referring below link and see there are lots of libraries and code need to implement … Is there any way to add libraries to application and server to get service db down metrics details?
(Java service)

Can you please suggest something so i will start analysis?