My application is based on the hibernate to fetched data from a mysql server. This mysql server is replicated to another mysql server instance. Today, I got a downtime as the primary database server was gone down without any notice. To avoid any future accidental problem, I am planing to add a functionality that will enable system to connect to secondary database if it finds the primary down.
Is there exists a way by which, I can leverage hibernate library to enable this functionality?
I have created following class after getting an idea form this thread
It seems to be working well. I don’t know if this is a good approach at all.