0

我正在使用 JBOSS EAP 5.1 想要实现主/从机制。xyz-mysql-ds.xml(例如客户数据库) xyz-mysql-ds.common.xml(普通数据库)

我在 xyz-mysql-ds.xml 中添加了主/从 ip

<local-tx-datasource>
<jndi-name>customerDS</jndi-name>
<use-java-context>false</use-java-context>    
<connection-url>jdbc:mysql:replication://master_ip_address:3306,slave_ip_address:3306/customer_v2_local?loadBalancePingTimeout=1500;loadBalanceBlacklistTimeout=7000;autoReconnect=true;failOverReadOnly=true;roundRobinLoadBalance=true</connection-url> 

<driver-class>com.mysql.jdbc.ReplicationDriver</driver-class> 

它成功启动了JBOSS。但在运行时出现以下错误

MySQLSyntaxErrorException: Unknown column 'lkpmenuopt0_.SortOrder' in 'field list'com.mysql.jdbc.exceptions.jdbc4.M
ySQLSyntaxErrorException: Unknown column 'lkpmenuopt0_.SortOrder' in 'field list'
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.Util.getInstance(Util.java:386)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
        at com.mysql.jdbc.LoadBalancedMySQLConnection.execSQL(LoadBalancedMySQLConnection.java:155)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
        at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2281)
        at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:342)

        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
        at org.hibernate.loader.Loader.doQuery(Loader.java:696)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
        at org.hibernate.loader.Loader.doList(Loader.java:2233)
 [wrapped] org.hibernate.exception.SQLGrammarException: could not execute query
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
        at org.hibernate.loader.Loader.doList(Loader.java:2236)

>>org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org
.hibernate.exception.SQLGrammarException: could not execute query
>>org.hibernate.exception.SQLGrammarException: could not execute query
[SQL: 1054, 42S22]
>>com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'lkpmenuopt0_.SortOrder' in 'field list
'
>>      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>>      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>>      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>>      at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
>>      at com.mysql.jdbc.Util.getInstance(Util.java:386)
>>      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
>>      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
>>      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
>>      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
>>      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
>>      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
>>      at com.mysql.jdbc.LoadBalancedMySQLConnection.execSQL(LoadBalancedMySQLConnection.java:155)

...

...

如果从以下位置删除字关系:<connection-url>jdbc:mysql:replication: 它不会在运行时异常的情况下工作,但所有读/写请求都只发送给主机。

有什么提示可以解决这个问题吗?

谢谢 !

4

1 回答 1

0

<connection-url>jdbc:mysql:replication://master:3306,slave:3306/Customerdb? loadBalancePingTimeout=1500 &amp;loadBalanceBlacklistTimeout=7000 &amp;autoReconnect=true &amp;failOverReadOnly=true &amp;roundRobinLoadBalance=true</connection-url>

<connection-url>jdbc:mysql:replication://master:3306,slave:3306/Customerdb?loadBalancePingTimeout=1500&amp;loadBalanceBlacklistTimeout=7000&amp;autoReconnect=true&amp;failOverReadOnly=true&amp;roundRobinLoadBalance=true</connection-url>

**最后这对我有用&amp;

于 2013-07-25T18:52:56.583 回答