双ip的oracle集群该怎么连接,jdbc连接oracle集群 如果Oracle有双IP

JDBC连接Oracle RAC集群问题

2010-02-21 11:29

You would need to configure your tnsnames.ora with the following information in the following way: RAC_DB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = node1)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = node2)(PORT = 1521)) (LOAD_BALANCE = yes) (FAILOVER = on) ) (CONNECT_DATA = (SERVICE_NAME = RAC_DB) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 20) (DELAY = 10) ) ) ) Now if you start a SQL*PLUS session, then you should see a connection on the node1 instance. If you start another SQL*PLUS session, then Oracle should connect you to the node2 instance (automatic load balancing). It's actually pretty cool to see the first time. To pass this same information to the Oracle's JDBC thin driver, you essentially concatenate a shorten version of the tnsnames information above and pass this to the driver. String userid = "scott"; String password = "tiger"; String tnsnames_info = "(DESCRIPTION=(ADDRESS_LIST=" + "(ADDRESS=(PROTOCOL=TCP)(HOST=node1)(PORT=1521))" + "(ADDRESS=(PROTOCOL=TCP)(HOST=node2)(PORT=1521))" + "(LOAD_BALANCE=yes)(FAILOVER=on))" + "(CONNECT_DATA=(SERVICE_NAME=rac_db)))" ; String url = "jdbc:oracle:thin:@" + tnsnames_info; DriverManager.registerDriver(new oracle.jdbc.OracleDriver()); Connection dbConnection = DriverManager.getConnection(url, userid, password);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值