Apache Ignite Documentation

GridGain Developer Hub - Apache Ignitetm

Welcome to the Apache Ignite developer hub run by GridGain. Here you'll find comprehensive guides and documentation to help you start working with Apache Ignite as quickly as possible, as well as support if you get stuck.

 

GridGain also provides Community Edition which is a distribution of Apache Ignite made available by GridGain. It is the fastest and easiest way to get started with Apache Ignite. The Community Edition is generally more stable than the Apache Ignite release available from the Apache Ignite website and may contain extra bug fixes and features that have not made it yet into the release on the Apache website.

 

Let's jump right in!

 

Documentation     Ask a Question     Download

 

Javadoc     Scaladoc     Examples

JDBC Driver

Connect to Ignite using standard JDBC driver.

Ignite is shipped with JDBC driver that allows you to retrieve distributed data from cache using standard SQL queries and JDBC API.

JDBC Connection

In Ignite, JDBC connection URL has the following pattern:

jdbc:ignite://<hostname>:<port>/<cache_name>
  • Hostname is required.
  • If port is not defined, 11211 is used (default for Ignite client).
  • Leave <cache_name> empty if you are connecting to a default cache. Note that the cache name is case sensitive.

Cross-Cache Queries

Cache that the driver is connected to is treated as the default schema. To query across multiple caches, Cross-Cache Query functionality can be used.

Joins and Collocation

Just like with Cache SQL Queries used from IgniteCache API, joins on PARTITIONED caches will work correctly only if joined objects are stored in collocated mode. Refer to Affinity Collocation for more details.

Replicated vs Partitioned Caches

Queries on REPLICATED caches will run directly only on one node, while queries on PARTITIONED caches are distributed across all cache nodes.

Configuration

Internally, JDBC driver is based on Ignite Java client. Therefore, all client configuration properties can be applied to JDBC connection. Client configuration properties can be defined in Properties object passed to DriverManager.getConnection(String, Properties) method. Possible properties are:

Properties
Description
Default

ignite.client.protocol

Communication protocol (TCP or HTTP).

TCP

ignite.client.connectTimeout

Socket connection timeout.

0 (infinite timeout)

ignite.client.tcp.noDelay

Flag indicating whether TCP_NODELAY flag should be enabled for outgoing connections.

true

ignite.client.ssl.enabled

Flag indicating that SSL is needed for connection. If SSL is enabled, ignite.client.ssl.keystore.location and ignite.client.ssl.truststore.location properties are required.

false

ignite.client.ssl.protocol

SSL protocol (SSL or TLS).

TLS

ignite.client.ssl.key.algorithm

Key manager algorithm.

SunX509

ignite.client.ssl.keystore.location

Key store to be used by client to connect with GridGain topology. This property is required if SSL is enabled.

ignite.client.ssl.keystore.password

Key store password.

ignite.client.ssl.keystore.type

Key store type.

jks

ignite.client.ssl.truststore.location

Trust store to be used by client to connect with GridGain topology. This property is required if SSL is enabled.

ignite.client.ssl.truststore.password

Trust store password.

ignite.client.ssl.truststore.type

Trust store type.

jks

ignite.client.credentials

Client credentials used in authentication process.

ignite.client.cache.top

Flag indicating that topology is cached internally. Cache will be refreshed in the background with interval defined by ignite.client.topology.refresh property (see below).

false

ignite.client.topology.refresh

Topology cache refresh frequency (ms).

2000 ms

ignite.client.idleTimeout

Maximum amount of time that connection can be idle before it is closed (ms).

30000 ms

Example

Ignite JDBC driver automatically gets only those fields that you actually need from objects stored in cache. For example, let's say you have Person class declared like this:

public class Person {
    @QuerySqlField
    private String name;
 
    @QuerySqlField
    private int age;
 
    // Getters and setters.
    ...
}

If you have instances of this class in cache, you can query individual fields (name, age or both) via standard JDBC API, like so:

// Register JDBC driver.
Class.forName("org.apache.ignite.IgniteJdbcDriver");
 
// Open JDBC connection (cache name is empty, which means that we use default cache).
Connection conn = DriverManager.getConnection("jdbc:ignite://localhost:11211/");
 
// Query names of all people.
ResultSet rs = conn.createStatement().executeQuery("select name from Person");
 
while (rs.next()) {
    String name = rs.getString(1);
    ...
}
 
// Query people with specific age using prepared statement.
PreparedStatement stmt = conn.prepareStatement("select name, age from Person where age = ?");
 
stmt.setInt(1, 30);
 
ResultSet rs = stmt.executeQuery();
 
while (rs.next()) {
    String name = rs.getString("name");
    int age = rs.getInt("age");
    ...
}

JDBC Driver


Connect to Ignite using standard JDBC driver.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.