Connecting Anaplan Connect to Snowflake Using JDBC Driver with Java 16 or Higher

AnaplanOEG
edited March 5 in Best Practices

Addressing JDBC Driver Compatibility Issues

Intended Audience

Level of Difficulty: Intermediate

  • Requires some familiarity with APIs, scripting, or database concepts

Resources Required:

  • Internal Expertise: Data Engineer/IT Admin/Integration Admin
  • Tools Needed: Anaplan Connect, Snowflake, Notepad Editor
  • Access Requirements: Snowflake database, Anaplan model/s

Estimated Level of Effort (LoE): Low

  • A few hours to a day

Introduction

This article provides a comprehensive guide to integrating Anaplan Connect with a Snowflake database using Java versions 16 or higher. It specifically addresses the known compatibility issues between Snowflake's JDBC driver and JDK 16 and later versions, offering solutions to ensure a seamless connection.​

Scope

This guide covers the following aspects:​

  • Installing Java 16 or higher
  • Downloading and configuring the Snowflake JDBC driver
  • Modifying Anaplan Connect client script to resolve compatibility issues
  • Testing the integration between Anaplan Connect and Snowflake

It does not cover the basics of Anaplan Connect or Snowflake setup; familiarity with these platforms is assumed and can be referenced here.

Prerequisites

Before proceeding, ensure you have the following:

  • Java Development Kit (JDK) 16 or higher installed on your system
  • Anaplan Connect 4.xx installed
  • Access to the Snowflake JDBC driver compatible with your Java version
  • Necessary permissions to access the Snowflake database
  • Basic knowledge of configuring and running Anaplan Connect scripts

Understanding the Compatibility Issue

With the release of JDK 16, stricter encapsulation of internal APIs was introduced, leading to compatibility issues with certain libraries, including Snowflake's JDBC driver. Users have reported encountering exceptions such as java.lang.ExceptionInInitializerError when attempting to use the Snowflake JDBC driver with JDK 16 or later. ​JDBC Driver Compatibility Issue With JDK 16 and Later

Integration Overview

Integrating Anaplan Connect with Snowflake involves configuring the JDBC connection to facilitate data transfer between the two platforms. Due to the compatibility issues introduced in JDK 16, specific adjustments are necessary to ensure successful connectivity.​

Step-by-Step Guide

Step 1: Install Java 16 or Higher

Ensure that JDK 16 or a later version is installed on your system. You can download the latest JDK from the official Oracle website or use an open-source alternative like OpenJDK.​

Step 2: Download and Configure the Snowflake JDBC Driver

  1. Download the Driver: Obtain the latest version of the Snowflake JDBC driver from the official Snowflake documentation.​
  2. Place the Driver: Copy the downloaded snowflake-jdbc-#.#.#.jar file into the <anaplan-connect>/lib directory.​

Step 3: Modify Anaplan Connect Client file to Address Compatibility

To resolve the compatibility issues between Snowflake's JDBC driver and JDK 16 or later, add the following JVM argument to your Anaplan Connect Client script:

Arguments to Add:

-Djdk.module.illegalAccess=permit --add-opens java.base/java.nio=ALL-UNNAMED

MacOS/Linux:

AnaplanClient.sh (Line 83)

# Start the Java virtual machine
exec "${_java}" ${JAVA_OPTS} -classpath "${classpath}" -Djdk.module.illegalAccess=permit --add-opens java.base/java.nio=ALL-UNNAMED com.anaplan.client.Program "$@"

Windows:

AnaplanClient.bat (Line 167)

rem Start the Java virtual machine
"!JAVA!" %JAVA_OPTS% -classpath "%CP%" -Djdk.module.illegalAccess=permit --add-opens java.base/java.nio=ALL-UNNAMED com.anaplan.client.Program !args!
goto :eof

This adjustment enables the Bouncy Castle library, which helps in mitigating the compatibility issues.

Step 4: Test the Integration

  1. Run the Script: Execute your modified Anaplan Connect script.
  2. Verify Connectivity: Ensure that the connection to the Snowflake database is established without errors and that data import/export functions as expected.​

Common Issues and Troubleshooting

  • No Suitable Driver Found Error: Ensure that the Snowflake JDBC driver is correctly placed in the <anaplan-connect>/lib directory and that the classpath is properly set.​
  • Bouncy Castle Library Issues: If enabling Bouncy Castle doesn't resolve the issue, ensure that the library is correctly installed and accessible in your Java environment.​

Got feedback on this content? Let us know in the comments below.

Author: Jon Ferneau, Data Integration Principal, Operational Excellence Group (OEG)