---
title: JdbcDataSource
description: Manages connections to a JDBC data source.
component: pinggateway
version: 2023.11
page_id: pinggateway:reference:JdbcDataSource
canonical_url: https://docs.pingidentity.com/pinggateway/2026/reference/JdbcDataSource.html
llms_txt: https://docs.pingidentity.com/pinggateway/llms.txt
docs_for_agents: https://developer.pingidentity.com/build-with-ai/docs-for-agents.md
revdate: 2025-06-03T11:21:31Z
superseded_by: https://docs.pingidentity.com/pinggateway/2026/reference/JdbcDataSource.html
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`. See the [Properties](MiscellaneousConfigurationObjects.html#JdbcDataSource-properties).

* `"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](MiscellaneousConfigurationObjects.html#ScheduledExecutorService).

* `"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`. See the [Properties](MiscellaneousConfigurationObjects.html#JdbcDataSource-properties).

* `"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 being used. The values of the object are evaluated as configuration expression<[strings](preface.html#definition-string)>.

  For information about available options, refer to the data source documentation.

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

  The [SecretsProvider](secrets.html#SecretsProvider) to use to resolve queried secrets, such as passwords and cryptographic keys. Provide either the name of a SecretsProvider object defined in the heap or specify a SecretsProvider object inline.

  Default: The route's default secret service. For more information, refer to [Default secrets object](secrets.html#default-secrets-object).

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

  The username to access the database.

## Example

For an example that uses JdbcDataSource, refer to [Log In With Credentials From a Database](../gateway-guide/sso-cdsso.html#credentials-database) and [Recording Access Audit Events in a Database](../maintenance-guide/auditing.html#audit-jdbc).

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

```json
"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:

```json
"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` does not provide enough information:

```json
"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)
