2.3.3 Configuring True Cache Database Application Services Manually

To use True Cache with the JDBC Thin driver, for each primary database application service that you want to cache, create a corresponding True Cache database application service.

This makes it easy for applications to switch an existing JDBC connection from a primary database to True Cache without having to change the JDBC connection URL. This is possible with the 23ai JDBC Thin driver by setting the ReadOnly parameter of the connection to TRUE or FALSE.

2.3.3.1 Create Database Application Services on the Primary Database

From the primary database, create or modify the True Cache and primary database services using one of the following methods.

  • For True Cache and single instance primary databases, use the DBMS_SERVICE PL/SQL package.For services that are specific to a pluggable database (PDB), connect to the specific PDB, or set the correct PDB container in your session before starting the service using DBMS_SERVICE.

  • For Oracle RAC primary databases, use the srvctl command line utility with the -true_cache_service option. Start the service on the primary instance. Use srvctl only for clusterware-managed instances.

    srvctl add service -db primary_db_unique_name -service primary_db_service_name -preferred primary_db_instance_list -pdb primary_pdb_name -true_cache_service true_cache_service_name

    For example:

    srvctl add service -db primdb1i -service sales -preferred primdb1i1,primdb1i2 -pdb sales_pdb -true_cache_service sales_tc

You can associate one primary database service with one True Cache service.

Here's an example of creating these two services using the DBMS_SERVICE package for a single instance primary database:

DECLARE
    db_params dbms_service.svc_parameter_array;
BEGIN
   -- create a database application service for True Cache called SALES_TC using SALES_TC tnsname
   DBMS_SERVICE.CREATE_SERVICE('SALES_TC', 'SALES_TC', db_params);

   -- create a database application service SALES for primary database using SALES tnsname and associate it to the SALES_TC service name using TRUE_CACHE_SERVICE attribute
   db_params('true_cache_service') := 'SALES_TC';
   DBMS_SERVICE.CREATE_SERVICE('SALES', 'SALES', db_params);

   -- or, modify an already existing primary database application service called SALES to associate it to the SALES_TC service name using the TRUE_CACHE_SERVICE attribute
   db_params('true_cache_service') := 'SALES_TC';
   DBMS_SERVICE.MODIFY_SERVICE('SALES', db_params);

END;

2.3.3.2 Verify That the Database Application Services Are Created

After you create services on the primary database, True Cache automatically inherits their definitions. Using SQL*Plus, make sure that you can see the same results on both the primary database and True Cache.

For example:

connect / as SYSDBA
SELECT name, true_cache_service FROM DBA_SERVICES WHERE name='SALES' or name='SALES_TC';

NAME        TRUE_CACHE_SERVICE
--------    ------------------
SALES_TC
SALES       SALES_TC

2.3.3.3 Start the Database Application Services

Using SQL*Plus, start the database application services on both the primary database and True Cache.

Example 2-1 True Cache

connect / as SYSDBA
SELECT database_role FROM v$database;

DATABASE_ROLE
-------------
TRUE CACHE
EXEC DBMS_SERVICE.START_SERVICE('SALES_TC');
SELECT service_id, name FROM v$active_services WHERE name='SALES_TC';

SERVICE_ID  NAME
----------  ---------
        28  SALES_TC

Example 2-2 Primary Database

connect / as SYSDBA
SELECT database_role FROM v$database;

DATABASE_ROLE
-------------
PRIMARY
EXEC DBMS_SERVICE.START_SERVICE('SALES');
SELECT service_id, name, true_cache_service FROM v$active_services WHERE name='SALES';

SERVICE_ID   NAME    TRUE_CACHE_SERVICE
----------   ------  ----------------
        29   SALES   SALES_TC