Skip to content

Instantly share code, notes, and snippets.

@Kuassim
Created August 22, 2023 16:17
Show Gist options
  • Save Kuassim/350e775c6dcf7b4448418c920b4f9425 to your computer and use it in GitHub Desktop.
Save Kuassim/350e775c6dcf7b4448418c920b4f9425 to your computer and use it in GitHub Desktop.
OracleDataSource ods = new oracle.jdbc.pool.OracleDataSource();
ods.setURL(DB_URL);
ods.setUser(DB_USER);
ods.setPassword(DB_PASSWORD);
Properties props = new Properties();
props.setProperty("oracle.jdbc.useTrueCacheDriverConnection", "true");
ods.setConnectionProperties(props);
// this is a True Cache driver connection and it can be used to execute
// queries on both the primary database and a True Cache instance
Connection conn = ods.getConnection();
Statement stmt = conn.createStatement();
// Default value of connection read-only flag is false which means
// the SQL_QUERY1 is executed on the primary database
ResultSet rs = stmt.executeQuery(SQL_QUERY1);
// set the read-only flag to true, in order to execute SQL_QUERY2
// on a True Cache instance
conn.setReadOnly(true);
ResultSet rs1 = stmt.executeQuery(SQL_QUERY2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment