当时在弄无线城市的时候,就碰到这个问题了,从那时到现在,我一直都认为jboss的数据源只能填一个ip。。。天真。
JBoss下采用thin driver连接 Oracle RAC,数据源需要这样配:
<local-tx-datasource>
<jndi-name>OracleDS</jndi-name>
<connection-url>jdbc:oracle:thin:@(description=(address_list=(address=(host=192.168.10.15)(protocol=tcp)(port=1521))(address=(host=192.168.10.16)(protocol=tcp)(port=1521))(load_balance=yes)(failover=yes))(connect_data=(service_name=ydpt)))</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>ytxt</user-name>
<password>ytxt123</password>
<!-- <user-name>ydpt</user-name>
<password>ydpt</password>-->
。。。。。。。。
</local-tx-datasource>
网上有人说,那个host填ip不行,需要填什么主机名的
转自:http://jbossweek.iteye.com/blog/138932
RAC的配置如下:
node1:ip地址192.168.10.1,实例名:rac1,主机名:x1
node2:ip地址192.168.10.2,实例名:rac2,主机名:x2
RAC服务名为x
配置过程如下:
1、google了一下,发现Bea网站提供的连接RAC方法最多,拷贝了如下的jdbcURL:
jdbc:oracle:thin:@(description=(address_list= (address=(host=192.168.10.1) (protocol=tcp)(port=1521))(address=(host=192.168.10.2)(protocol=tcp) (port=1521)) (load_balance=yes)(failover=yes))(connect_data=(service_name= x)))
但是出现如下错误:
Io 异常: NL Exception was generated;
2、又从网上google、baidu一番,虽然找到n方法,但就是连不上;
3、无奈之中,打开数据库tnsname.ora,发现其中的配置如下:
x=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = x1)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = x2)(PORT = 1521))
(LOAD_BALANCE = yes)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = x)
)
)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = x1)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = x2)(PORT = 1521))
(LOAD_BALANCE = yes)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = x)
)
)
于是将jdbcUR修改成:
jdbc:oracle:thin:@(description=(address_list= (address=(host=x1) (protocol=tcp)(port=1521))(address=(host=x2)(protocol=tcp) (port=1521)) (load_balance=yes)(failover=yes))(connect_data=(service_name= x)))
测试一下,结果竟然成功了;初步认为是:数据库服务采用主机名,而在jdbcURL中采用ip地址的方式就会出现NL Exception的问题;
建议:对于连接RAC有问题的情况,最好使用tnsnames.ora中连接字符串进行连接;
问题:oracle的thin和oci连接方式有什么不同?