---
title: JdbcDataSource
description: Manages connections to a JDBC data source.
component: pinggateway
version: 2026
page_id: pinggateway:reference:JdbcDataSource
canonical_url: https://docs.pingidentity.com/pinggateway/2026/reference/JdbcDataSource.html
revdate: 2025-07-07T11:49:11Z
section_ids:
  JdbcDataSource-usage: Usage
  JdbcDataSource-properties: Properties
  JdbcDataSource-example: Example
  JdbcDataSource-moreinfo: More information
---

# JdbcDataSource

Manages connections to a JDBC data source.

To configure the connection pool, add a JdbcDataSource object named `AuditService` in the route heap.

## Usage

```json
{
  "name": string,
  "type": "JdbcDataSource",
  "config": {
    "dataSourceClassName": configuration expression<string>,
    "driverClassName": configuration expression<string>,
    "executor": ScheduledExectutorService reference,
    "jdbcUrl": configuration expression<url>,
    "passwordSecretId": configuration expression<secret-id>,
    "poolName": configuration expression<string>,
    "properties": object,
    "secretsProvider": SecretsProvider reference,
    "username": configuration expression<string>
  }
}
```

## Properties

* `"dataSourceClassName"`: *configuration expression<[string](preface.html#definition-string)>, optional*

  The data source class name to use to connect to the database.

  Depending on the underlying data source, use either `jdbcUrl`, or `dataSourceClassName` with `url`.

* `"driverClassName"`: *configuration expression<[string](preface.html#definition-string)>, optional*

  Class name of the JDBC connection driver. The following examples can be used:

  * MySQL Connector/J: `com.mysql.jdbc.Driver`

  * H2: `org.h2.Driver`

  This property is optional, but required for older JDBC drivers.

* `"executor"`: *ScheduledExecutorService [reference](preface.html#definition-reference), optional*

  A ScheduledExecutorService for maintenance tasks.

  Default: [ScheduledExecutorService](ScheduledExecutorService.html).

* `"jdbcUrl"`: *configuration expression<[url](preface.html#definition-url)>, optional*

  The JDBC URL to use to connect to the database.

  Depending on the underlying data source, use either `jdbcUrl`, or `dataSourceClassName` with `url`.

* `"passwordSecretId"`: *configuration expression<[secret-id](preface.html#definition-secretid)>, required if the database is password-protected*

  The secret ID of the password to access the database.

  This secret ID must point to a [GenericSecret](../security-guide/keys.html#secret-types).

* `"poolName"`: *configuration expression<[string](preface.html#definition-string)>, optional*

  The connection pool name. Use to identify a pool easily for maintenance and monitoring.

* `"properties"`: *[object](preface.html#definition-object), optional*

  Server properties specific to the type of data source used. PingGateway evaluates each value of the object as a configuration expression<[string](preface.html#definition-string)>.

  Learn more in [PingGateway route properties](Properties.html) and in the documentation for the data source.

* `"secretsProvider"`: *SecretsProvider [reference](preface.html#definition-reference), required*

  The [SecretsProvider](SecretsProvider.html) to query for passwords and cryptographic keys.

* `"username"`: *configuration expression<[string](preface.html#definition-string)>, optional*

  The username to access the database.

## Example

You can find an example that uses JdbcDataSource in [Password replay from a database](../gateway-guide/credentials-database.html).

The following example configures a JdbcDataSource with a `dataSourceClassName` and `url`:

```none
"config": {
  "username": "testUser",
  "dataSourceClassName": "org.h2.jdbcx.JdbcDataSource",
  "properties": {
    "url": "jdbc:h2://localhost:3306/auth"
  },
  "passwordSecretId": "database.password",
  "secretsProvider": "MySecretsProvider"
}
```

The following example configures a JdbcDataSource with `jdbcUrl` alone:

```none
"config": {
  "username": "testUser",
  "jdbcUrl": "jdbc:h2://localhost:3306/auth",
  "passwordSecretId": "database.password",
  "secretsProvider": "MySecretsProvider"
}
```

The following example configures a JdbcDataSource with `jdbcUrl` and `driverName`. Use this format for older drivers, where `jdbcUrl` doesn't provide enough information:

```none
"config": {
  "username": "testUser",
  "jdbcUrl": "jdbc:h2://localhost:3306/auth",
  "driverName": "org.h2.Driver",
  "passwordSecretId": "database.password",
  "secretsProvider": "MySecretsProvider"
}
```

## More information

[org.forgerock.openig.sql.JdbcDataSourceHeaplet](../_attachments/apidocs/org/forgerock/openig/sql/JdbcDataSourceHeaplet.html)
