Oracle|Oracle RAC JDBC connection string - multitude - 博客园
完全正确
【Oracle|Oracle RAC JDBC connection string - multitude - 博客园】 https://stackoverflow.com/questions/1646630/what-is-the-correct-jdbc-url-to-connect-to-a-rac-database
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=OFF)(FAILOVER=ON) (ADDRESS=(PROTOCOL=TCP)(HOST=tst-db1.myco.com)(PORT=1604)) (ADDRESS=(PROTOCOL=TCP)(HOST=tst-db2.myco.com)(PORT=1604))) (CONNECT_DATA=https://www.it610.com/article/(SERVICE_NAME=mydb1.myco.com)(SERVER=DEDICATED)))
官方文档, 一如既往地冗长, 可靠
https://docs.oracle.com/database/121/HABPT/config_fcf.htm#HABPT5381
文章图片
文章图片
PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource(); pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource"); pds.setUser("system"); pds.setPassword("oracle"); String dbURL = "jdbc:oracle:thin:@" + "(DESCRIPTION=" + "(FAILOVER=on)" + "(ADDRESS_LIST=" + "(LOAD_BALANCE=on)" + "(CONNECT_TIMEOUT=3)(RETRY_COUNT=3)" + "(ADDRESS=(PROTOCOL=TCP)(HOST=prmy-scan)(PORT=1521))"+"(ADDRESS=(PROTOCOL=TCP)(HOST= stby-scan)(PORT=1521)))" + "(CONNECT_DATA=https://www.it610.com/article/(SERVICE_NAME=oltpworkload)))" System.out.println("Url=" + dbURL); pds.setURL(dbURL);
文章图片
文章图片
文章图片
"jdbc:oracle:thin:@" + "(DESCRIPTION=" + "(FAILOVER=on)" + "(ADDRESS_LIST=" + "(LOAD_BALANCE=on)" + "(CONNECT_TIMEOUT=3)(RETRY_COUNT=3)" + "(ADDRESS=(PROTOCOL=TCP)(HOST=prmy-scan)(PORT=1521))"+"(ADDRESS=(PROTOCOL=TCP)(HOST= stby-scan)(PORT=1521)))" + "(CONNECT_DATA=https://www.it610.com/article/(SERVICE_NAME=oltpworkload)))"
文章图片
文章图片
PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource(); pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource"); pds.setUser("system"); pds.setPassword("oracle"); String dbURL = "jdbc:oracle:thin:@" + "(DESCRIPTION_LIST=" + "(LOAD_BALANCE=off)" + "(FAILOVER=on)" + "(DESCRIPTION=" + "(CONNECT_TIMEOUT=3)(RETRY_COUNT=3)" + "(ADDRESS_LIST=" + "(LOAD_BALANCE=on)" + "(ADDRESS=(PROTOCOL=TCP)(HOST=prmy-scan)(PORT=1521)))" + "(CONNECT_DATA=https://www.it610.com/article/(SERVICE_NAME=oltpworkload)))" + "(DESCRIPTION=" + "(ADDRESS_LIST=" + "(LOAD_BALANCE=on)" + "(ADDRESS=(PROTOCOL=TCP)(HOST= stby-scan)(PORT=1521)))" + "(CONNECT_DATA=https://www.it610.com/article/(SERVICE_NAME=oltpworkload))))"; System.out.println("Url=" + dbURL); pds.setURL(dbURL);
文章图片
这个第三方总结很简单, 看样子是第三方驱动厂商
https://support.tibco.com/s/article/JDBC-dbURL-when-using-failover-servers-with-Oracle
Resolution When creating the bootstrap use the following formats for the JDBC connection string.
Case 1: When using tibcosoftwareinc.jdbc.oracle.OracleDriver driver (Oracle (DataDirect)), JDBC URL field should contain:
jdbc:tibcosoftwareinc:oracle://: SID= AlternateServers=( : SID= )
Example URL:
jdbc:tibcosoftwareinc:oracle://host1:1521; ServiceName=orcl; AlternateServers=(host2:1521)
Case 2: When using oracle.jdbc.driver.OracleDriver (the native driver form Oracle), the JDBC URL field should contain:
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT= ))(SERVICE_NAME= ))(ADDRESS=(PROTOCOL=TCP)(HOST= )(PORT= ))(LOAD_BALANCE=yes)(CONNECT_DATA=https://www.it610.com/article/(SERVICE_NAME= )(FAILOVER_MODE=(TYPE=SELECT)(METHOD=BASIC)(RETRIES=180))))
Example URL:
jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=host1) (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=host2) (PORT=1521))(CONNECT_DATA=https://www.it610.com/article/(SERVICE_NAME=orcl)))
See more information inOracle's documentation. Reference Oracle documentation:Configuring Fast Connection Failover for JDBC Clients
推荐阅读
- C#抽象abstract
- Oracle面试经验|S62(校园服务器技术)
- Oracle面试经验|S28(应用开发工程师)
- AndroidStudio导入项目出现Your project path contains non-ASCII characters错误
- Win8系统无法安装Oracle10g怎样办?
- Android开发学习—— 创建项目时,不是继承activity,而是继承ActionBarActivity
- android 使用jdbc1.3.0 操作 sql server
- ado.net数据提供者
- Tesseract OCR集成Android Studio实现OCR识别
- Android性能优化之TraceView和Lint使用详解