【发布时间】:2017-07-10 21:00:00
【问题描述】:
我想在 SpringBoot 应用程序中的 application.yml 中有一个带有 2 个不同架构/数据库名称的 jdbc url。
我通过关注Reference Link 尝试了这些,但不幸的是我无法让它工作。
jdbc:mysql://address=(type=master)(protocol=tcp)(host=IP1)(port=3306)(user=root)(password=root)/dbname1?failOverReadOnly=false,address=(type=master)(protocol=tcp)(host=IP2)(port=3306)(user=test)(password=test)/dbname2?failOverReadOnly=false
jdbc:mysql://address=(type=master)(protocol=tcp)(host=IP1)(port=3306)(user=root)(password=root)(dbname=dbname1)?failOverReadOnly=false,address=(type=master)(protocol=tcp)(host=IP2)(port=3306)(user=test)(password=test)(dbname=dbname2)?failOverReadOnly=false
我收到的错误是在启动应用程序时,因为 MySQL 连接器无法解析 url 连接字符串。
2017-02-21 11:37:40.724] log4j - 3060 ERROR [main] --- o.a.t.j.p.ConnectionPool: Unable to create initial connections of pool.
java.sql.SQLException: The connection property 'failOverReadOnly' only accepts values of the form: 'true', 'false', 'yes' or 'no'. The value 'false,address=(type=master)(protocol=tcp)(host=localhost)(port=3306)(user=test)(password=test)/dbname2?failOverReadOnly=false' is not in this set.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
【问题讨论】:
-
您遇到错误了吗?
-
我在启动服务器并且连接器解析连接 url 时收到错误
-
错误信息和您粘贴的代码不匹配。在您的代码中,它显示“user=root”,错误显示“user=test”(以及其他差异)。
标签: java mysql jdbc spring-boot mysql-connector