webMethods Digital Event Persistence 10.3 | Establishing a Connection to an Elasticsearch Cluster and Index | Establishing a Connection Using the JDBC Driver Manager
 
Establishing a Connection Using the JDBC Driver Manager
The examples in this section show you how to establish a connection to an Elasticsearch index and cluster, using the JDBC Driver Manager.
First, the following code shows how you pass the required property "installDir" and use the JDBC Driver Manager to create a connection to a locally installed Elasticsearch and the index orders.
String url = "jdbc:evp:elasticsearch:5.6.4://localhost:9300/cluster_name/orders";
Properties info = new Properties();
info.setProperty("installDir", path_to_JDBC_driver_installation_directory);
If the Elasticsearch instance you are connecting to is enabled for Secure Sockets Layer (SSL) with the Search Guard plugin, you must pass these additional properties:
info.setProperty("useSSL", true);
info.setProperty("keystore", "path_to_the_JKS_keystore_file");
info.setProperty("keystorePassword", "unencrypted_JKS_keystore_password");
info.setProperty("truststore", "path_to_the_JKS_truststore_file");
info.setProperty("truststorePassword", "unencrypted_JKS_truststore_password")
Then, use the following code to establish the connection:
try (Connection connection = DriverManager.getConnection(url, info)) {
    assertTrue(connection != null);
}

Copyright © 2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.