How do I set up our MySQL ReplicationDriver for our JBoss 7 datasource?
Used MySql 5.5.37 and JBoss 7.1.3 and mysql-connector-java-5.1.22-bin.jar. How do I configure the original Jaboss source standalone.xml to connect to our master-slave configuration for MySQL? I tried below
<datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql:replication//master.amazonaws.com:3306,slave.amazonaws.com:3306/dbsid?failOverReadOnly=true;roundRobinLoadBalance=true</connection-url>
<driver>mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>sb</user-name>
<password>sb</password>
</security>
<statement>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.ReplicationDriver</xa-datasource-class>
</driver>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
But when I restart my server I get an exception ...
Caused by: javax.resource.ResourceException: Wrong driver class [class com.mysql.jdbc.Driver] for this connection URL [jdbc:mysql:replication//master.amazonaws.com:3306,slave.amazonaws.com:3306/dbsid?failOverReadOnly=true;roundRobinLoadBalance=true]
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:256)
... 47 more
I opened the JAR and confirmed that the ReplicationDriver class is there. Not sure what else I should try.
source to share
The driver implementation is chosen based on the connecting URL.
If you specify a connection URL like this: "jdbc: mysql: replication // ..", the MySQL / J connector returns the ReplicationDriver implementation.
If you set the driver class to com.mysql.jdbc.ReplicationDriver, all your data sources will be decoded as "replication url" and must always contain a master and at least one slave.
I think it is better to choose the correct implementation with URL customization (replication, balancing, fabric ...).
source to share