JDBC Driver for Adobe Analytics

Build 24.0.9060

Caching Metadata

This section describes how to enable caching metadata and how to update the metadata cache.

Before being able to query data, the connector requires relevant metadata to be retrieved. By default, metadata is cached in memory and shared across connections. But if you want to persist across processes, or if metadata requests are expensive, the solution is to cache the metadata to disk.

Enable Caching Metadata

To enable caching of metadata, set CacheMetadata = true and see Configuring the Cache Connection for instructions on how to configure your connection string. The driver caches the metadata the first time it is needed and uses the metadata cache for subsequent requests.

Update the Metadata Cache

Because metadata is cached, changes to metadata on the live source, for example, adding or removing a column or attribute, are not automatically reflected in the metadata cache. To get updates to the live metadata, you need to delete or drop the cached data.

Cache Metadata from Code

The following code can be used to build the metadata cache. This is especially useful when using the Object-Relational Mapping Framework (for example, Hibernate).

Connection conn = DriverManager.getConnection("jdbc:adobeanalytics:Cache Location=C:\\cdata.adobeanalytics.db;AutoCache=True;InitiateOAuth=GETANDREFRESH;");
DatabaseMetaData table_meta = conn.getMetaData();

ResultSet rs=table_meta.getTables(null, null, "%", null); 

while (rs.next()) {
  String tableName = rs.getString("TABLE_NAME");
  System.out.println("Cached metadata for table: "+tableName);
  ResultSet cols = table_meta.getColumns(null, null, tableName, null);
  while(rs.next()){
  }
}
System.out.println();
System.out.println("All tables cached.");
conn.close();

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060