Establishing a ConnectionCData JDBC Driver for Elasticsearch 2019 - Build 19.0.7354
Creating a JDBC Data Source
You can create a JDBC data source to connect from your Java application. Creating a JDBC data source based on the CData JDBC Driver for Elasticsearch 2019 consists of three basic steps:
- Add the driver JAR file to the classpath. The JAR file is located in the lib subfolder of the installation directory. Note that the .lic file must be located in the same folder as the JAR file.
- Provide the driver class. For example:
- Provide the JDBC URL. For example:
jdbc:elasticsearch:Server=127.0.0.1;Port=9200; or jdbc:cdata:elasticsearch:Server=127.0.0.1;Port=9200;
The second format above can be used whenever there is a conflict in your application between drivers using the same URL format to ensure you are using the CData driver. The URL must start with either "jdbc:elasticsearch:" or "jdbc:cdata:elasticsearch:" and can include any of the connection properties in name-value pairs separated with semicolons.
Connecting to Elasticsearch
Set the Server and Port connection properties, in addition to the authentication properties. The CData JDBC Driver for Elasticsearch 2019 uses X-Pack Security for authentication and TLS/SSL encryption.
Authenticating to Elasticsearch
Set the User and Password properties and/or use PKI (public key infrastructure) to authenticate. Once the driver is connected, X-Pack performs user authentication and grants role permissions based on the realms you have configured.
To use PKI, set the SSLClientCert, SSLClientCertType, SSLClientCertSubject, and SSLClientCertPassword properties.
Note: TLS/SSL and client authentication must be enabled on X-Pack to use PKI.
Securing Elasticsearch Connections
To enable TLS/SSL in the driver, prefix the Server value with 'https://'.
Connecting to Amazon Elasticsearch Service
To connect to Amazon ES, set the Server, Port, AccessKey, SecretKey, and Region properties.
- Server should be set to the Endpoint URL for the Amazon ES instance.
- Port should be set to 443.
- Region should be set to the Amazon AWS region where the Elasticsearch instance is being hosted (the driver will attempt to automatically identify the region based on the Server value).
The AccessKey and SecretKey properties are used to authenticate an AWS user. Note: Requests are signed using AWS Signature Version 4.