Created
August 22, 2023 16:17
-
-
Save Kuassim/350e775c6dcf7b4448418c920b4f9425 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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