如何为JBoss 7数据源配置MySQL ReplicationDriver? [英] How do I configure our MySQL ReplicationDriver for our JBoss 7 data source?

查看:143
本文介绍了如何为JBoss 7数据源配置MySQL ReplicationDriver?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用MySql 5.5.37和JBoss 7.1.3,以及mysql-connector-java-5.1.22-bin.jar.如何配置JBoss的standalone.xml数据源以连接到MySQL的主从配置?我尝试了以下

We’re using MySql 5.5.37 and JBoss 7.1.3, and mysql-connector-java-5.1.22-bin.jar. How do I configure my JBoss’ standalone.xml datasource to connect to our master-slave configuration for MySQL? I tried the 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 the 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

我打开了JAR,并确认其中存在ReplicationDriver类.不知道我还应该尝试什么.

I opened my JAR and verified the ReplicationDriver class is in there. Not sure what else I should be trying.

推荐答案

不知道为什么要搞乱xa-datasource-class元素,但是对我有用的是

Not sure why I was messing around with xa-datasource-class elements, but what worked for me was

                <driver name="mysql" module="com.mysql">
                    <driver-class>com.mysql.jdbc.ReplicationDriver</driver-class>
                </driver>

这篇关于如何为JBoss 7数据源配置MySQL ReplicationDriver?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆