Home >Database >Mysql Tutorial >JDBC连接oracle RAC数据库配置

JDBC连接oracle RAC数据库配置

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 15:32:481890browse

RAC的配置如下: node1 : ip 地址 192.168.60.132 ,实例名: rac1 ,主机名: rac1 node2 : ip 地址 192.168.60.144 ,实例名: rac2 ,主机名: rac2 RAC 服务名为 oratest 我的应用服务器为 apache + tomcat 配置过程如下 1、搜索了一下,发现提供的连

RAC的配置如下:

 

node1ip地址192.168.60.132,实例名:rac1,主机名:rac1

 

node2ip地址192.168.60.144,实例名:rac2,主机名:rac2

 

RAC服务名为oratest

我的应用服务器为apachetomcat

 

 

 

 

配置过程如下

 

1、搜索了一下,发现提供的连接RAC方法很多,拷贝了如下的jdbcURL:     

 

jdbc:oracle:thin:@(description=(address_list= (address=(host=192.168.60.132) (protocol=tcp)(port=1521))(address=(host=192.168.60.144)(protocol=tcp) (port=1521)) (load_balance=yes)(failover=yes))(connect_data=(service_name= oratest)))

 

但是tomcat报出如下错误:

Io 异常: NL Exception was generated;

 

2、又从网上google、baidu一番,虽然找到n方法,但就是连不上,总是提示这个错误;

 

3、无奈之中,打开数据库tnsname.ora,发现其中的配置如下:

 oratest=

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521))

      (ADDRESS = (PROTOCOL = TCP)(HOST = rac2)(PORT = 1521))

      (LOAD_BALANCE = yes)

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = oratest)

    )

  )

于是将jdbcUR修改成:

jdbc:oracle:thin:@(description=(address_list= (address=(host=rac1) (protocol=tcp)(port=1521))(address=(host=rac2)(protocol=tcp) (port=1521)) (load_balance=yes)(failover=yes))(connect_data=(service_name= oratest)))

 

测试一下,结果竟然成功了;

初步认为是:数据库服务采用主机名,而在jdbcURL中采用ip地址的方式就会出现NL Exception的问题;

 

建议:对于连接RAC有问题的情况,最好使用tnsnames.ora中连接字符串进行连接;

 

 不知道大家有没有遇到这样的问题?

Statement:
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
Previous article:L1和L2正则化Next article:新浪微博API授权