博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Multi-Host Connections(三)
阅读量:7055 次
发布时间:2019-06-28

本文共 978 字,大约阅读时间需要 3 分钟。

hot3.png

ReplicationDriver

针对Master/Slave,Mysql jdbc drivrer : ReplicationDriver

  1. Perform read/write work on the master by setting the read-only flag to "false"

conn.setReadOnly(false);

  1. Now, do a query from a slave, the driver automatically picks one from the list

conn.setReadOnly(true);

URL配置样式:jdbc:mysql:replication://master,slave1,slave2,slave3/test?roundRobinLoadBalance=true

  几种MySQL JDBC 驱动的URL前缀:  

URL_PREFIX = "jdbc:mysql://";

REPLICATION_URL_PREFIX = "jdbc:mysql:replication://";

MXJ_URL_PREFIX = "jdbc:mysql:mxj://";

LOADBALANCE_URL_PREFIX = "jdbc:mysql:loadbalance://";

jdbc:mysql:fabric://

 

另外一种配置方式:

jdbc:mysql://address=(type=master)(host=master1host),address=(type=master)(host=master2host),address=(type=slave)(host=slave1host)/database

 

replication drivers举例

jdbc:mysql:replication//master.amazonaws.com:3306,slave.amazonaws.com:3306/dbsid?failOverReadOnly=true;roundRobinLoadBalance=true&allowMasterDownConnections=true

转载于:https://my.oschina.net/masterworker/blog/1825406

你可能感兴趣的文章
C语言基本概念(7)
查看>>
autoload-cache-1.7 发布
查看>>
autoload-cache-2.4 发布
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
了解CDP持续数据保护
查看>>
2011 Web设计的10大趋势
查看>>
centos6.5 下 mysql数据库的安装与配置
查看>>
SQL Server 维护计划
查看>>
快速低成本的搭建一个马马虎虎的博客
查看>>
Squid + DNS配置CDN加速服务器(概念篇)
查看>>
Spring数据库操作组件
查看>>
lanmp v2.5安装soap支持方法
查看>>
普华永道发表2012年全球信息安全状况调查报告
查看>>
关于SIEM和LM产品形态的小调查
查看>>
我的eclipse插件列表
查看>>
老板决策不当,是自己在“找死”
查看>>
JS创建类和对象
查看>>
linkcloud:KVM虚拟化渐趋成熟 可与XEN和Vmware比肩
查看>>
3月9日作业
查看>>