How ReplicationDriver works
I am curious how com.mysql.jdbc.ReplicationDriver works. I have configuration with 1master & 1slave.
I want to force some queries to JUST on开发者_开发问答 slave. But it selects DB randomly and sometimes run it on master.
Is it a way to force readonly connection to use just slave DB and never master?
For the ReplicationDriver to know that queries can go to read-only slaves, two conditions need to be met:
Auto commit needs to be turned off. (*)
Connection needs to be set to read-only.
精彩评论