JDBC连接Oracle RAC的连接串配置
2009-02-25 10:43
le/digest/2008/06/jdbcoracle_rac.html 这里虽然引用了eygle的文章,但我要说这样的写法是不准确的。JDBC Thin 到目前为止,仍是不支持TAF的,而且将来也应该不会支持。Oracle的推荐做法是FCF。但这样写也没有任何影响,至少到目前为止,尚未发现。它使得 中断的连接在重连时可以获得正确的连接。这样来讲,可能一般的应用真的不需要TAF。 Feature Differences Between JDBC OCI and JDBC Thin Drivers
Feature List
详细信息请参看 B28359_01/java.111/b31224/overvw.htm#BABJFBIF 这个连接串通常写在中间件里,是否 Native XA 和 连接时的 Failover 已经足够了呢?那么 FCF 更广泛的意义是什么呢?据说,在BEA被收购前,只有Oracle自家的App Server 支持 FCF,不知道现在的情形是什么样子。 jdbc连接oracle的连接串如下: String url="jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = host2)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = host1)(PORT = 1521))(LOAD_BALANCE = yes)(FAILOVER = ON)(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = db.domain)(FAILOVER_MODE=(TYPE = SELECT)(METHOD = BASIC)(RETIRES = 20)(DELAY = 15))))"; 红部分为可以删掉的部分,因为那是OCI的写法。 java测试程序如下: import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class Test { public static void main(String arg[]) { try { Class.forName("oracle.jdbc.driver.OracleDriver"); String url="jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = host1)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = host2)(PORT = 1521))(LOAD_BALANCE = yes)(FAILOVER = ON)(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = db.domain)(FAILOVER_MODE=(TYPE = SELECT)(METHOD = BASIC)(RETIRES = 20)(DELAY = 15))))"; Connection c = Connection(url,"aa","aa"); Statement s = c.createStatement(); jdbc连接oracleResultSet r = s.executeQuery("select 1 from dual"); ()) { System.out.String(1)); } }catch(Exception e) { System.out.String()); } } } 附加查看会话的故障切换信息的 SQL 查询 COLUMN instance_name FORMAT a13 COLUMN host_name FORMAT a9 COLUMN failover_method FORMAT a15 COLUMN failed_over FORMAT a11 SELECT instance_name , host_name , NULL AS failover_type , NULL AS failover_method , NULL AS failed_over FROM v$instance UNION SELECT NULL , NULL , failover_type , failover_method , failed_over FROM v$session WHERE username = 'SYSTEM'; INSTANCE_NAME HOST_NAME FAILOVER_TYPE FAILOVER_METHOD FAILED_OVER ------------- --------- ------------- --------------- ----------- orcl1 linux1 SELECT BASIC NO 详细请参看 acle/technology/global/cn/pub/articles/hunter_rac10gr2_iscsi_3.html 新增Oracle官方FCF Demo: acle/technology/products/ias/hi_av/fcf_viewlet_swf.html | ||||||||||||||||||||||||||||||||||||||||||||||
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论