我无法获得可重播的数据源(代码附在下面)。
PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource();
pds.setConnectionFactoryClassName("oracle.jdbc.replay.OracleDataSourceImpl");
System.out.println("connection factory set");
String URL = "jdbc:oracle:thin:@(DESCRIPTION = (TRANSPORT_CONNECT_TIMEOUT=3) (RETRY_COUNT=20)(FAILOVER=ON) " +
" (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = " +
" (SERVER = DEDICATED) (SERVICE_NAME=orcl)))";
System.out.println("Using URL\n" + URL);
pds.setURL(URL);
pds.setUser("system");
pds.setPassword("oracle");
pds.setInitialPoolSize(10);
pds.setMinPoolSize(10);
pds.setMaxPoolSize(20);
pds.setConnectionWaitTimeout(10);
// RAC Features
pds.setConnectionPoolName("Application Continuity Pool");
pds.setFastConnectionFailoverEnabled(true);
System.out.println("pool configured, trying to get a connection");
Connection conn = null;
try{
conn = pds.getConnection();
}catch(Exception e){
e.printStackTrace();
}
if (conn == null || !((ValidConnection) conn).isValid()) {
System.out.println("connection is not valid");
throw new Exception ("invalid connection obtained from the pool");
}
if ( conn instanceof oracle.jdbc.replay.ReplayableConnection ) {
System.out.println("got a replay data source");
} else {
System.out.println("this is not a replay data source. Why not?");
}
下面是我从上面的代码中得到的系统打印,它显示连接实例不是可重放的类型。
连接工厂设置 使用 URL jdbc:oracle:thin:@(DESCRIPTION = (TRANSPORT_CONNECT_TIMEOUT=3) (RETRY_COUNT=20)(FAILOVER=ON) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) ( CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl))) 池已配置,试图 获取连接这不是重放数据源。为什么不?
我从以下站点获取代码并进行了一些修改以添加线程并模拟 AC。但我无法获得可重播的数据源。
https://martincarstenbach.wordpress.com/2013/12/13/playing-with-application-continuity-in-rac-12c/