JDBC 连接到 Oracle Clustered
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/855556/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JDBC connection to Oracle Clustered
提问by Tam
I would like to connect to a clustered Oracle database described by this TNS:
我想连接到此 TNS 描述的集群 Oracle 数据库:
MYDB=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host1)(PORT = 41521))
(ADDRESS = (PROTOCOL = TCP)(HOST = host2)(PORT = 41521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME= PDSALPO)
)
)
I connect normally from my application to non-clustered Oracle using the following configuration:
我使用以下配置从我的应用程序正常连接到非集群 Oracle:
<group name="jdbc">
<prop name="url">jdbc:oracle:thin:@host1:41521:PDSALPO</prop>
<prop name="username">user</prop>
<prop name="password">pass</prop>
</group>
Do you know how I can change that to connect to the clustered database?
你知道我如何改变它以连接到集群数据库吗?
Thanks,
谢谢,
Tam
谭
回答by Matthew Watson
Apparently you can do this
显然你可以这样做
jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=host1)
(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=host2)
(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=service)))
回答by Tam
You can use this format, unless you make use of JTA transactions. In that case you must use some different setup. See http://forums.oracle.com/forums/thread.jspa?messageID=2860653�(applies for BEA Weblogic, but I think it also applies for other setups and application servers)
您可以使用这种格式,除非您使用 JTA 事务。在这种情况下,您必须使用一些不同的设置。参见http://forums.oracle.com/forums/thread.jspa?messageID=2860653ꙭ(适用于 BEA Weblogic,但我认为它也适用于其他设置和应用服务器)