java - Using MySQL replication (Master/Slave) with MyBatis -


i wondering how can use master/slave mysql replication database mybatis. jdbc offers com.mysql.jdbc.replicationdriver (see here), couldn't find out can use similar things including nice properties can configure (roundrobinloadbalance, autoreconnect,...) in mybatis.

currently have configured none-replicated database in mybatis this:

<environments default="development">     <environment id="development">         <transactionmanager type="jdbc" />         <datasource type="pooled">             <property name="driver" value="com.mysql.jdbc.driver" />             <property name="url"                 value="jdbc:mysql://localhost:3306/database" />             <property name="username" value="root" />             <property name="password" value="" />         </datasource>     </environment>     <environment id="production">         <transactionmanager type="jdbc" />         <datasource type="pooled">             <property name="driver" value="com.mysql.jdbc.driver" />             <property name="url"                 value="jdbc:mysql://xxx:3306/database" />             <property name="username" value="production" />             <property name="password" value="" />         </datasource>     </environment> </environments> 

has a hint me?

thanks help.

daniel

another possible answer

if notice, properties you're setting in xml driver common properties set , passed jdbc. so, wouldn't surprised if mybatis taking them , passing them right driver. maybe try this:

<environments default="development">     <environment id="development">         <transactionmanager type="jdbc" />         <datasource type="pooled">             <!-- use replicationdriver -->             <property name="driver" value="com.mysql.jdbc.replicationdriver" />             <property name="url"                 value="jdbc:mysql://localhost:3306/database" />             <property name="autoreconnect" value="true" />             <property name="roundrobinloadbalance" value="true" />             <property name="username" value="root" />             <property name="password" value="" />         </datasource>     </environment>     <environment id="production">         <transactionmanager type="jdbc" />         <datasource type="pooled">             <!-- use replicationdriver -->             <property name="driver" value="com.mysql.jdbc.replicationdriver" />             <property name="url"                 value="jdbc:mysql://xxx:3306/database" />             <property name="autoreconnect" value="true" />             <property name="roundrobinloadbalance" value="true" />             <property name="username" value="production" />             <property name="password" value="" />         </datasource>     </environment> </environments> 

Comments