Elasticsearch’s SQL jdbc driver is a rich, fully featured JDBC driver for Elasticsearch. It is Type 4 driver, meaning it is a platform independent, stand-alone, Direct to Database, pure Java driver that converts JDBC calls to Elasticsearch SQL.
The JDBC driver can be obtained from:
<dependency> <groupId>org.elasticsearch.plugin</groupId> <artifactId>x-pack-sql-jdbc</artifactId> <version>7.17.15</version> </dependency>
from Maven Central Repository,
artifacts.elastic.co/maven by adding it to the repositories list:
<repositories> <repository> <id>elastic.co</id> <url>https://artifacts.elastic.co/maven</url> </repository> </repositories>
Your driver must be compatible with your Elasticsearch server version.
The driver version cannot be newer than the Elasticsearch server version. For example, A 7.10.0 server is not compatible with 7.17.15 drivers.
|Elasticsearch server version||Compatible driver versions||Example|
A 7.10.0 server is compatible with 7.7.0-7.10.0 drivers.
7.7.0 and earlier versions
A 7.6.1 server is only compatible with 7.6.1 drivers.
The driver main class is
Note the driver implements the JDBC 4.0
Service Provider mechanism meaning it is registered automatically
as long as it is available in the classpath.
Once registered, the driver understands the following syntax as an URL:
- Prefix. Mandatory.
Type of HTTP connection to make. Possible values are
localhostby default) and port (
9200by default). Optional.
- Prefix (empty by default). Typically used when hosting Elasticsearch under a certain path. Optional.
- Properties for the JDBC driver. Empty by default. Optional.
The driver recognized the following properties:
timezone(default JVM timezone)
Timezone used by the driver per connection indicated by its
ID. Highly recommended to set it (to, say,
UTC) as the JVM timezone can vary, is global for the entire JVM and can’t be changed easily when running under a security manager.
- Connection timeout (in milliseconds). That is the maximum amount of time waiting to make a connection to the server.
- Network timeout (in milliseconds). That is the maximum amount of time waiting for the network.
- Page size (in entries). The number of results returned per page by the server.
Page timeout (in milliseconds). Minimum retention period for the scroll cursor on the server. Queries that require
a stateful scroll cursor on the server side might fail after this timeout. Hence, when scrolling through large result sets,
page.sizerecords should not take longer than
- Query timeout (in milliseconds). That is the maximum amount of time waiting for a query to return.
- Basic Authentication user name
- Basic Authentication password
- Enable SSL
- key store (if used) location
- key store password
key store type.
PKCS12is a common, alternative format
- trust store location
- trust store password
trust store type.
PKCS12is a common, alternative format
- SSL protocol to be used
- Http proxy host name
- SOCKS proxy host name
- Whether to be lenient and return the first value (without any guarantees of what that will be - typically the first in natural ascending order) for fields with multiple values (true) or throw an exception.
- Whether to include frozen-indices in the query execution or not (default).
Default catalog (cluster) for queries. If unspecified, the queries execute on the data in the local cluster only.
[preview] This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. See cross-cluster search.
- If disabled, it will ignore any misspellings or unrecognizable properties. When enabled, an exception will be thrown if the provided property cannot be recognized.
To put all of it together, the following URL:
opens up a Elasticsearch SQL connection to
server on port
3456, setting the JDBC connection timezone to
UTC and its pagesize to