我有一个Grails(2.2.1)应用程序,我正在尝试配置MySQL复制。这些设置通过“grails run-app”正常工作,但在通过Tomcat运行时失败:
dataSource {
dbCreate = "update"
url = "jdbc:mysql:replication://app1-db.cykm5cykm5.us-east-1.rds.amazonaws.com,app1-db-rr1.cykm5cykm5.us-east-1.rds.amazonaws.com/app1_production?useUnicode=true&characterEncoding=UTF-8"
driverClassName = "com.mysql.jdbc.ReplicationDriver"
username = "Username"
password = "Password"
properties {
defaultReadOnly = false
initialSize = 10
maxActive = 110
maxIdle = 60
minIdle = 10
maxWait = 10000
}
}
抛出的异常是:
Caused by: java.sql.SQLException: Must specify at least one slave host to connect to for master/slave replication load-balancing functionality
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
at com.mysql.jdbc.NonRegisteringDriver.connectReplicationConnection(NonRegisteringDriver.java:393)
at com.mysql.jdbc.NonRegisteringReplicationDriver.connect(NonRegisteringReplicationDriver.java:52)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
... 8 more
知道为什么我会看到这个异常,为什么在运行grails dev服务器时它没有出现?
提前致谢。
答案 0 :(得分:0)
这证明了定义第二个数据源的问题。正在为两个数据源加载复制驱动程序,即使第二个数据源具有非复制连接字符串。
使用可复制友好的连接字符串配置第二个数据源解决了这个问题。