我无法获得可重播的数据源(代码附在下面)。
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)(地址) =(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/
答案 0 :(得分:0)
请确保您的类路径中有oracle.jdbc.replay.OracleDataSourceImpl,换句话说,请确保您的类路径中有12.1.0.2 JDBC驱动程序。