Home > Database > Mysql Tutorial > JDBC 连接 Oracle 11gR2 集群环境

JDBC 连接 Oracle 11gR2 集群环境

WBOY
Release: 2016-06-07 17:21:40
Original
1115 people have browsed it

JDBC 连接 Oracle 11gR2 集群环境,使用Oracle 11gR2新组件 scan 方式连接(假设scan_vip为192.168.100.217)

使用Oracle 11gR2新组件 scan 方式连接(假设scan_vip为192.168.100.217)
String url = "jdbc:oracle:thin:@192.168.100.217:1521/prod"
也可以使用 11gr2以前vip方式连接
String url = "jdbc:oracle:thin:@(DESCRIPTION ="
              + "(ADDRESS_LIST ="
              + "(ADDRESS=(PROTOCOL=TCP)(HOST=el1)(PORT=1521))"
              + "(ADDRESS=(PROTOCOL=TCP)(HOST=el2)(PORT=1521))"
              + "(LOAD_BALANCE = yes)"
              + ")" + "(CONNECT_DATA=" + "(SERVER=DEDICATED)"
              + "(SERVICE_NAME=prod )" + ")" + ")";

注:jdbc thin使用 11gr2以前 vip方式连接, host中不可以直接使用 ip,否则会出现NL Exception was generated 错误。需要使用别名。并且在 hosts文件中定义。

例如本例中两台机器的 vip为 192.168.100.123和 192.168.100.124并且,别名为 el1, el2。那么在 hosts文件中需要有下面两行
192.168.100.123 el1
192.168.100.124 el2

host文件位置:
Linux|Unix:/etc/hosts
Windows:$系统盘\WINDOWS\system32\drivers\etc\hosts

下面是一个完整的实例:

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template