A newer version of Platform is available.

View latest

Mapping to JDBC

To query external JDBC data stores, you can create a mapping to them with the JDBC connector.

What is the JDBC Connector

The JDBC connector allows you to connect to any database that supports the JDBC interface.

Supported SQL Statements

The JDBC connector supports only the following statements:

Installing the Connector

The JDBC connector is included in the full and slim distributions of Hazelcast.

Permissions

Enterprise

The JDBC connector does not yet support permissions.

Before you Begin

Before you can create a mapping to an external data store, you must have the following:

  • A JDBC driver that’s compatible with your data store. This driver must be on the classpath of your cluster members:

    • The full distribution of Hazelcast comes with a JDBC driver for MySQL, PostgreSQL, and H2 data stores, but currently Hazelcast Enterprise does not include a JDBC driver for MySQL.

    • The slim distribution of Hazelcast does not come with a JDBC driver.

  • A data store connection that’s configured on all cluster members.

  • Create the database that you’ll use as your external data store.

Creating a JDBC Mapping

The following example creates a mapping to a MySQL database.

In the MySQL database, create a people table.

CREATE TABLE people (id INT PRIMARY KEY, name VARCHAR(100))

Use the CREATE MAPPING statement to tell the JDBC connector the name of your data store configuration.

external-data-store:
  mysql-database: (1)
    class-name: com.hazelcast.datastore.JdbcDataStoreFactory
    properties:
      jdbcUrl: jdbc:mysql://dummy:3306
      username: xyz
      password: xyz
    shared: true
1 Configuration details for a MySQL database.

Create the mapping.

CREATE MAPPING people
TYPE JDBC (1)
OPTIONS (
  'externalDataStoreRef'='mysql-database' (2)
)
1 The name of the connector.
2 The name of the external data store configuration on your members.