Enhance connection fail-over with master/slave restriction and loadbalancing

If multiple hosts are specified in the jdbc connection url then:
- Adds querying of node writability and possibility to restrict connections to writable or read-only nodes.
- Adds load balancing of connections.
- Uses a JVM global cache of known node states.

Based on work by chenhj@cn.fujitsu.com from 2011. I rewrote most of the code, added more documentation and integrated properly the tests.