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.
<dependency> <groupId>org.elasticsearch.plugin</groupId> <artifactId>jdbc</artifactId> <version>6.3.0</version> </dependency>
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>
The driver main class is
org.elasticsearch.xpack.sql.jdbc.jdbc.JdbcDriver. Note the driver
also implements the JDBC 4.0
Service Provider mechanism meaning it is registerd automatically
as long as its available in the classpath.
Once registered, the driver expects the following syntax as an URL:
type of HTTP connection to make -
prefix (empty by default). Typically used when hosting Elasticsearch under a certain path. Optional.
Parameters for the JDBC driver. Empty by default. Optional.
The driver recognized the following parameters:
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 seconds). That is the maximum amount of time waiting to make a connection to the server.
- Network timeout (in seconds). That is the maximum amount of time waiting for the network.
- Page timeout (in seconds). That is the maximum amount of time waiting for a page.
- Page size (in entries). The number of results returned per page by the server.
- Query timeout (in seconds). 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
- Whether or not to allow self signed certificates
- SSL protocol to be used
- Http proxy host name
- SOCKS proxy host name
To put all of it together, the following URL: