我使用TNS字符串作为我的Grails数据源的url,带有两个oracle DB(ora01,ora02)。它在正常操作期间连接到db服务ok。这是配置:
dbString = "jdbc:oracle:thin:@(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = ora01.foo)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = ora02.bar)(PORT = 1521))
)
(CONNECT_DATA = (SERVICE_NAME = orastage)))"
dataSource
{
pooled = true
driverClassName = "oracle.jdbc.OracleDriver"
username = foo
password = bar
url = dbString
logSql = false
}
当DBA关闭ora01并重新启动ora02作为活动版时,Grails应用程序无法实现并抛出JDBC错误:
2013-04-26 11:41:35,428 ERROR JDBCTransaction - JDBC commit failed
java.sql.SQLRecoverableException: No more data to read from socket
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1142)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1099)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:288)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C7Ocommoncall.doOCOMMIT(T4C7Ocommoncall.java:75)
at oracle.jdbc.driver.T4CConnection.doCommit(T4CConnection.java:565)
at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:3851)
at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:3857)
at org.apache.commons.dbcp.DelegatingConnection.commit(DelegatingConnection.java:334)
我的配置看起来不错吗?我假设Grails可以在我们尝试使用db之前将TNS字符串作为数据源URL连接好 - 这是正确的吗?这就像应用程序仍在尝试连接到死数据库而不是尝试其他节点。我是否需要让Grails做一些特定的事情来切换到现在正在运行的节点?
答案 0 :(得分:0)
尝试在说明中使用(FAILOVER=ON)
。
dbString = "jdbc:oracle:thin:@(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = ON)
(FAILOVER=ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = ora01.foo)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = ora02.bar)(PORT = 1521))
)
(CONNECT_DATA = (SERVICE_NAME = orastage)))"