Setup Guide

SQL Provisioning

This page explains how to configure the SQL Connector (AKA DatabaseTableConnector) in a Memority ConnectorDefinition.

Overview

The SQL Connector reads and writes the rows of one table (or view) in a relational database. Each row is one account.

Item

Value

Connector class (connectorRef.connectorName)

org.identityconnectors.databasetable.DatabaseTableConnector

Supported databases

PostgreSQL, Oracle, MySQL, Microsoft SQL Server

Object classes

__ACCOUNT__ only

Supported Operations

Create, Get/Search, Update, Delete, Test, Schema, Pagination on keyColumn, Live Sync (optional), Authenticate (optional)

Supported databases and JDBC drivers

This table lists the database technologies supported by the SQL Connector:

Database

JDBC driver artifact

Driver version

PostgreSQL

org.postgresql:postgresql

Platform version

Oracle

com.oracle.database.jdbc:ojdbc8

23.2.0.0

MySQL

com.mysql:mysql-connector-j

8.0.33

Microsoft SQL Server

com.microsoft.sqlserver:mssql-jdbc

13.4.0.jre11

How the connector maps the table

The connector reads the table structure when it starts. It builds the schema from the column list.

Table column

Memority / ConnId attribute

Notes

Column name configured in keyColumn

__NAME__ and __UID__

Both have the same value. The column must be unique and not null. Searches read the rows page by page in the order of this column, so an index on it is recommended. If you update __NAME__, the key value changes and the __UID__ changes too.

Column name configured in passwordColumn

__PASSWORD__

Optional. The password is written as is (clear text). The connector does not hash it.

Column configured in changeLogColumn

(hidden)

Used only for Live Sync. It is not in the schema and is not returned.

All other columns

Attribute with the column name

The attribute name uses the case returned by the database. Oracle usually returns UPPERCASE names; PostgreSQL returns lowercase names. A NOT NULL column becomes a required attribute. Binary columns are not returned by default.

Other rules:

  • All attributes are single-valued.

  • Without allNative=true, the connector reads and writes most values as strings.

  • To write a timestamp as a string, use the format yyyy-MM-dd HH:mm:ss (for example 2024-02-23 10:37:24), or the number of milliseconds since 1970.

  • The connector uses a transaction for each operation (auto-commit is off).

  • On Oracle, the connector turns on synonyms automatically.

How to set properties in a ConnectorDefinition

Set the connector properties in ConnectorDefinition.connectorProperties. Each property is a name / value pair. All values are strings. Memority converts them to the right type.

Rule

Details

Property names are case-sensitive

Use the exact names in the table of section 4. An unknown name is ignored without error (only a debug log). Check the spelling.

Boolean values

true or false. Any other value means false.

Integer values

A plain number, for example 5.

Multi-valued values (String[])

Add the property several times (one value each), or give one value with commas: 23505,23000. A single value is always split on commas.

Secret values (password)

The value must be a secret URI: plain:<value> (test only) or settings:<setting-id> (recommended).

Value from a Setting

For a non-secret property, you can use settings:<setting-id> to read the value from a Memority Setting.

% in a JDBC URL

%h, %p and %d are placeholders. To write a real % character, write %%.

Minimal example (PostgreSQL)

JSON
{
  "connectorMetadata": {
    "connectorRef": { "connectorName": "org.identityconnectors.databasetable.DatabaseTableConnector" }
  },
  "connectorProperties": [
    { "name": "host",            "value": "db.example.com" },
    { "name": "port",            "value": "5432" },
    { "name": "database",        "value": "hr" },
    { "name": "user",            "value": "svc_memority" },
    { "name": "password",        "value": "settings:hr-db-password" },
    { "name": "table",           "value": "public.employees" },
    { "name": "keyColumn",       "value": "login" },
    { "name": "jdbcDriver",      "value": "org.postgresql.Driver" },
    { "name": "jdbcUrlTemplate", "value": "jdbc:postgresql://%h:%p/%d?sslmode=verify-full&sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory&socketTimeout=30" },
    { "name": "allNative",       "value": "true" }
  ]
}

Configuration properties

Database connection

Property

Type

Description

Mandatory

Default Value

Example

jdbcDriver

String

Class name of the JDBC driver. See the table in section 1.

Yes

oracle.jdbc.driver.OracleDriver

org.postgresql.Driver

jdbcUrlTemplate

String

JDBC connection URL. It can contain the placeholders %h (host), %p (port), %d (database). You can also write a full URL without placeholders. See section 5 for the parameters of each database.

Yes

jdbc:oracle:thin:@%h:%p:%d

jdbc:postgresql://%h:%p/%d?sslmode=verify-full

host

String

Host name or IP address of the database server. Replaces %h in the URL.

Yes, if the URL contains %h

–

db.example.com

port

String

TCP port of the database server. Replaces %p in the URL.

Yes, if the URL contains %p

–

5432

database

String

Database name (Oracle: SID or service name). Replaces %d in the URL.

Yes, if the URL contains %d

–

hr

user

String

Database account used by the connector. It needs SELECT, INSERT, UPDATE and DELETE rights on the table (only SELECT for read-only use).

Yes

–

svc_memority

password

String (secret)

Password of the database account. Use a secret URI.

Yes

–

settings:hr-db-password

validConnectionQuery

String

SQL query used to check that a pooled connection is still alive. If empty, the connector uses the driver's own check.

No

– (driver check)

SELECT 1 (Oracle: SELECT 1 FROM DUAL)

validConnectionTimeout

int

Timeout (seconds) of the driver's own connection check. Used only if validConnectionQuery is empty.

No

5

10

Table mapping

Property

Type

Description

Mandatory

Default Value

Example

table

String

Name of the table (or view) that holds the accounts. You can add the schema: schema.table. The name is not quoted.

Yes

–

public.employees

keyColumn

String

Column that identifies a row. Mapped to __NAME__ and __UID__. Must be unique and not null. Searches are paged on this column: see “Search: paging and order”. Must be different from changeLogColumn and passwordColumn.

Yes

–

login

passwordColumn

String

Column that holds the account password. Mapped to __PASSWORD__. The value is written in clear text. If empty, there is no password attribute and no Authenticate operation.

No

–

password

suppressPassword

boolean

If true, the connector never returns the password, even if it is requested. If false, it returns the password when it is requested.

No

true

true

quoting

String

How column names are quoted in SQL. Values: none, double ("col"), single ('col'), back (`col`), brackets ([col]). Not case-sensitive.

No

– (none)

brackets

enableEmptyString

boolean

If true, write an empty string instead of NULL in a NOT NULL text column. No effect on Oracle (Oracle stores an empty string as NULL).

No

false

true

Data types

Property

Type

Description

Mandatory

Default Value

Example

allNative

boolean

If true, read and write all values with their native JDBC type (number, boolean, timestamp, …), and not as strings. Recommended for PostgreSQL, to handle timestamps. When true, nativeTimestamps is ignored.

No

false

true

nativeTimestamps

boolean

If true, read TIMESTAMP columns as native timestamps, then convert them to strings. Recommended for Oracle: the Oracle driver can return a wrong string for a timestamp. Used only if allNative is false.

No

false

true


Property

Type

Description

Mandatory

Default Value

Example

pageSize

int

Maximum number of rows read by one search query. The connector reads the table page by page, so a large table does not use too much memory. Must be between `1` and `10000`. A caller that gives its own page size (for example the account discovery) uses its value, limited to `10000`.

No

5000

2000

Search: paging and order

  • Paging is always on. The connector does not read the whole table at once: it reads `pageSize` rows, sorted by `keyColumn`, then the next `pageSize` rows, and so on until the end of the table.

  • Results always come in `keyColumn` order. A requested sort is ignored.

  • `keyColumn` must be unique and not null:

    • A row with a `NULL` key is never returned.

    • If a key value is in several rows (non unique), the connector logs a warning (`Key column <column> is not unique: duplicate key values: <n>, rows: <m>`) and returns all these rows in the same page. That page can be larger than `pageSize`, without limit.

  • On a view, uniqueness is not checked by the database. Check that the key column of the view has no duplicates.

  • Add an index on `keyColumn` (a primary key or a unique index is best). Without an index, each page is a full table scan.

  • Prefer a numeric key column. With a text key column, the order depends on the database collation.

Live Sync

Live Sync is available only if changeLogColumn is set.

Property

Type

Description

Mandatory

Default Value

Example

changeLogColumn

String

Column that holds the last change time (or an increasing number) of each row. The connector returns the rows whose value is greater than the last sync token. The token is the highest value of this column.

Yes, for Live Sync

– (no Live Sync)

updated_at

syncOrderColumn

String

Column used to sort the Live Sync results (ORDER BY). If empty, changeLogColumn is used. The name is not quoted.

No

– (changeLogColumn)

updated_at

syncOrderAsc

Boolean

Sort order of the Live Sync results: true = ascending, false = descending.

No

true

true

Error handling

Property

Type

Description

Mandatory

Default Value

Example

rethrowAllSQLExceptions

boolean

If false, SQL errors with error code 0 are ignored (some drivers send them when there is no real error). If true, all SQL errors are reported.

No

true

true

alreadyExistMessages

String

Comma-separated list of texts. During a create, if the SQL error message contains one of them, the connector reports "already exists".

No

–

duplicate key value,ORA-00001,Duplicate entry,Violation of PRIMARY KEY

SQLStateExceptionHandling

boolean

If true, use the SQLState codes below to classify SQL errors (instead of alreadyExistMessages).

No

false

true

SQLStateAlreadyExists

String[]

SQLState codes that mean "already exists" (for example a unique constraint violation).

No

–

23505 (PostgreSQL), 23000 (Oracle, MySQL, SQL Server)

SQLStateConnectionFailed

String[]

SQLState codes that mean "connection failed".

No

–

08001, 08006, 08S01

SQLStateInvalidAttributeValue

String[]

SQLState codes that mean "invalid attribute value".

No

–

22001, 23502

SQLStateConfigurationException

String[]

SQLState codes that mean "configuration error".

No

–

42P01, 42S02

JDBC connection parameters by database

Summary

Database

jdbcDriver

jdbcUrlTemplate

Default port

Recommended quoting

Recommended data type option

validConnectionQuery

PostgreSQL

org.postgresql.Driver

jdbc:postgresql://%h:%p/%d?<params>

5432

none (or double for mixed-case names)

allNative=true

SELECT 1

Oracle

oracle.jdbc.OracleDriver

Service name: jdbc:oracle:thin:@//%h:%p/%d
SID: jdbc:oracle:thin:@%h:%p:%d
TLS: jdbc:oracle:thin:@tcps://%h:%p/%d?<params>

1521 (TLS: often 2484)

none

nativeTimestamps=true

SELECT 1 FROM DUAL

MySQL

com.mysql.cj.jdbc.Driver

jdbc:mysql://%h:%p/%d?<params>

3306

back

–

SELECT 1

SQL Server

com.microsoft.sqlserver.jdbc.SQLServerDriver

jdbc:sqlserver://%h:%p;databaseName=%d;<params>

1433

brackets

–

SELECT 1

TLS certificates: The drivers check the server certificate against the trust store of the Memority platform. You cannot give a certificate file in the connector configuration. If the database uses a private CA, ask the Memority platform team to add the CA to the trust store.

Parameters that point to a file (key stores, wallets, root certificates) cannot be used: integrators have no access to the file system of the platform.

PostgreSQL

URL format: jdbc:postgresql://host:port/database?param1=value1&param2=value2

Reference example:

jdbc:postgresql://%h:%p/%d?ssl=true&sslmode=verify-full&sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory&socketTimeout=30

Parameter

Description

Values

Default

Example

ssl

Turns on TLS. With sslmode set, this parameter is not needed.

true, false

false

ssl=true

sslmode

TLS level. verify-full checks the certificate and the host name (recommended).

disable, allow, prefer, require, verify-ca, verify-full

prefer

sslmode=verify-full

sslfactory

Class that creates TLS connections. DefaultJavaSSLFactory uses the platform trust store (needed in Memority).

Class name

Driver internal factory (reads ~/.postgresql/root.crt)

sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory

connectTimeout

Timeout to open the TCP connection, in seconds. 0 = no timeout.

Integer

10

connectTimeout=10

socketTimeout

Timeout for a read on the socket, in seconds. 0 = no timeout. Protects against a stuck query or a dropped connection.

Integer

0

socketTimeout=30

loginTimeout

Timeout to connect and log in, in seconds.

Integer

0

loginTimeout=15

tcpKeepAlive

Sends TCP keep-alive packets. Helps when a firewall drops idle connections.

true, false

false

tcpKeepAlive=true

currentSchema

Schema search path. Lets you write table without the schema.

Schema name

–

currentSchema=hr

ApplicationName

Name shown in pg_stat_activity. Useful for the DBA.

String

PostgreSQL JDBC Driver

ApplicationName=memority

targetServerType

Server type to use with a multi-host URL.

any, primary, secondary, preferPrimary, preferSecondary

any

targetServerType=primary

Multi-host URL (failover): jdbc:postgresql://db1:5432,db2:5432/hr?targetServerType=primary

Oracle

URL formats:

Form

URL

Notes

Service name

jdbc:oracle:thin:@//%h:%p/%d

Recommended. %d = service name.

SID

jdbc:oracle:thin:@%h:%p:%d

Old form (connector default). %d = SID.

Easy Connect Plus (TLS and parameters)

jdbc:oracle:thin:@tcps://%h:%p/%d?param1=value1&param2=value2

Use tcps for TLS, tcp without TLS.

TNS descriptor

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=%h)(PORT=%p))(CONNECT_DATA=(SERVICE_NAME=%d)))

Full control.

Example:

jdbc:oracle:thin:@tcps://%h:%p/%d?ssl_server_dn_match=true&connect_timeout=10&oracle.jdbc.ReadTimeout=30000

Parameter

Description

Values

Default

Example

ssl_server_dn_match

With tcps: checks that the server certificate matches the host name.

true, false

true (driver 23)

ssl_server_dn_match=true

ssl_server_cert_dn

With tcps: exact distinguished name expected in the server certificate.

DN

–

ssl_server_cert_dn="CN=db.example.com"

connect_timeout

Timeout to open the connection, in seconds.

Integer

Driver default

connect_timeout=10

transport_connect_timeout

Timeout to open the TCP connection, in seconds.

Integer

Driver default

transport_connect_timeout=5

retry_count / retry_delay

Number of connection retries / delay between retries (seconds).

Integer

0 / 1

retry_count=3&retry_delay=2

oracle.jdbc.ReadTimeout

Timeout for a read on the socket, in milliseconds.

Integer

0 (no timeout)

oracle.jdbc.ReadTimeout=30000

oracle.net.CONNECT_TIMEOUT

Timeout to open the connection, in milliseconds (same purpose as connect_timeout).

Integer

Driver default

oracle.net.CONNECT_TIMEOUT=10000

Oracle notes:

  • Column names are usually returned in UPPERCASE. The attribute names in Memority are uppercase too (FIRST_NAME).

  • Keep quoting=none, unless the columns were created with quoted mixed-case names.

  • Set nativeTimestamps=true if the table has TIMESTAMP or DATE columns.

MySQL

URL format: jdbc:mysql://host:port/database?param1=value1&param2=value2

Example:

jdbc:mysql://%h:%p/%d?sslMode=VERIFY_IDENTITY&connectTimeout=10000&socketTimeout=30000&connectionTimeZone=UTC

Parameter

Description

Values

Default

Example

sslMode

TLS level. VERIFY_IDENTITY checks the certificate and the host name (recommended). Replaces the old useSSL.

DISABLED, PREFERRED, REQUIRED, VERIFY_CA, VERIFY_IDENTITY

PREFERRED

sslMode=VERIFY_IDENTITY

tlsVersions

Allowed TLS versions.

Comma-separated list

Driver default

tlsVersions=TLSv1.2,TLSv1.3

connectTimeout

Timeout to open the connection, in milliseconds. 0 = no timeout.

Integer

0

connectTimeout=10000

socketTimeout

Timeout for a read on the socket, in milliseconds. 0 = no timeout.

Integer

0

socketTimeout=30000

tcpKeepAlive

Sends TCP keep-alive packets.

true, false

true

tcpKeepAlive=true

connectionTimeZone

Time zone of the server, used to convert dates and timestamps (old name: serverTimezone).

Time zone ID, LOCAL, SERVER

LOCAL

connectionTimeZone=UTC

characterEncoding

Character set of the connection.

Java charset

Server setting

characterEncoding=UTF-8

zeroDateTimeBehavior

What to do with the date 0000-00-00.

EXCEPTION, ROUND, CONVERT_TO_NULL

EXCEPTION

zeroDateTimeBehavior=CONVERT_TO_NULL

allowPublicKeyRetrieval

Lets the driver get the server RSA key for caching_sha2_password without TLS. Do not use in production: use TLS instead.

true, false

false

–

MySQL notes:

  • Use quoting=back if column names are reserved words or contain special characters.

  • jdbcDriver must be com.mysql.cj.jdbc.Driver. The old class org.gjt.mm.mysql.Driver (shown in the connector help) does not exist in driver 8.

Microsoft SQL Server

URL format: jdbc:sqlserver://host:port;databaseName=database;param1=value1;param2=value2

Parameters are separated by ;, not by &.

Example:

jdbc:sqlserver://%h:%p;databaseName=%d;encrypt=true;trustServerCertificate=false;loginTimeout=15;socketTimeout=30000;applicationName=memority

Parameter

Description

Values

Default

Example

databaseName

Database name.

String

User default database

databaseName=%d

encrypt

Turns on TLS. strict uses TDS 8.0 (SQL Server 2022 and later).

true, false, strict

true

encrypt=true

trustServerCertificate

If true, the driver does not check the server certificate. Do not use in production.

true, false

false

trustServerCertificate=false

hostNameInCertificate

Host name expected in the server certificate, when it differs from the URL host.

Host name

URL host

hostNameInCertificate=*.database.windows.net

loginTimeout

Timeout to connect and log in, in seconds.

Integer

Driver default

loginTimeout=15

socketTimeout

Timeout for a read on the socket, in milliseconds. 0 = no timeout.

Integer

0

socketTimeout=30000

queryTimeout

Timeout for a query, in seconds. -1 = no timeout.

Integer

-1

queryTimeout=60

instanceName

Named instance. Use it instead of the port (the SQL Browser service must be reachable).

String

–

instanceName=SQLEXPRESS

applicationName

Name shown in the SQL Server sessions.

String

Microsoft JDBC Driver for SQL Server

applicationName=memority

multiSubnetFailover

Faster failover for an Always On availability group listener.

true, false

false

multiSubnetFailover=true

authentication

Authentication mode. Use SqlPassword with user and password.

SqlPassword, ActiveDirectoryPassword, …

NotSpecified (SQL login)

authentication=SqlPassword

sendStringParametersAsUnicode

If false, text values are sent as VARCHAR, not NVARCHAR. Can make searches on VARCHAR indexed columns faster. Keep true for NVARCHAR columns.

true, false

true

sendStringParametersAsUnicode=false

SQL Server notes:

  • Use quoting=brackets if column names are reserved words or contain spaces.

  • Windows integrated authentication (integratedSecurity=true) is not available in Memority.

Full configuration examples

PostgreSQL

Property

Value

jdbcDriver

org.postgresql.Driver

jdbcUrlTemplate

jdbc:postgresql://%h:%p/%d?sslmode=verify-full&sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory&socketTimeout=30

host

db.example.com

port

5432

database

hr

user

svc_memority

password

settings:hr-db-password

table

public.employees

keyColumn

login

allNative

true

changeLogColumn

updated_at

validConnectionQuery

SELECT 1

Oracle

Property

Value

jdbcDriver

oracle.jdbc.OracleDriver

jdbcUrlTemplate

jdbc:oracle:thin:@tcps://%h:%p/%d?ssl_server_dn_match=true&oracle.jdbc.ReadTimeout=30000

host

oracle.example.com

port

2484

database

HRPDB (service name)

user

SVC_MEMORITY

password

settings:hr-oracle-password

table

HR.EMPLOYEES

keyColumn

LOGIN

nativeTimestamps

true

validConnectionQuery

SELECT 1 FROM DUAL

MySQL

Property

Value

jdbcDriver

com.mysql.cj.jdbc.Driver

jdbcUrlTemplate

jdbc:mysql://%h:%p/%d?sslMode=VERIFY_IDENTITY&connectTimeout=10000&socketTimeout=30000

host

mysql.example.com

port

3306

database

hr

user

svc_memority

password

settings:hr-mysql-password

table

employees

keyColumn

login

quoting

back

validConnectionQuery

SELECT 1

SQL Server

Property

Value

jdbcDriver

com.microsoft.sqlserver.jdbc.SQLServerDriver

jdbcUrlTemplate

jdbc:sqlserver://%h:%p;databaseName=%d;encrypt=true;trustServerCertificate=false;loginTimeout=15;socketTimeout=30000

host

mssql.example.com

port

1433

database

HR

user

svc_memority

password

settings:hr-mssql-password

table

dbo.Employees

keyColumn

Login

quoting

brackets

validConnectionQuery

SELECT 1

Live Sync: how it works and limits

  • The first sync token is the highest value of changeLogColumn in the table. Live Sync starts from "now". It does not return existing rows: use a reconciliation for the first import.

  • At each run, the connector reads the rows where changeLogColumn > last token, sorted by syncOrderColumn (or changeLogColumn).

  • Each row is returned as a create or update. Deletions are not detected. Use a reconciliation, or a status column (soft delete), to handle deletions.

  • The application that writes the table must update changeLogColumn at each change. A database trigger is the safest way.

  • Use a column type with enough precision (timestamp with milliseconds, or an increasing sequence). A row committed late with an older value than the last token is missed.

Troubleshooting

Symptom

Probable cause

Fix

JDBC Driver is not found on classpath.

Wrong jdbcDriver, or a database that Memority does not support.

Use a driver class from section 1.

The connector connects to Oracle by mistake, or fails with an Oracle URL.

jdbcDriver / jdbcUrlTemplate not set: the Oracle defaults are used.

Set both properties.

Host/Port/Database configuration property is empty.

The URL contains %h, %p or %d, but the property is empty.

Set the property, or remove the placeholder from the URL.

Can not read from the table or view '…'.

Wrong table name, missing schema, or missing SELECT right.

Check table (add the schema) and the database rights.

The key column should not be the same as changelog column.

keyColumn = changeLogColumn.

Use two different columns.

A property has no effect.

The property name is wrong: unknown names are ignored.

Check the exact name (case-sensitive).

Wrong or shifted timestamp values.

String conversion of timestamps.

PostgreSQL: allNative=true. Oracle: nativeTimestamps=true. MySQL: set connectionTimeZone.

An attribute is not found on Oracle.

Oracle returns uppercase column names.

Use the uppercase name in the mapping (FIRST_NAME).

Operations hang when the database or the network fails.

No socket timeout.

Add the socket/read timeout parameter of the driver (section 5).

TLS error: certificate not trusted.

The database CA is not in the platform trust store.

Ask the Memority platform team to add the CA.

Page size must be between 1 and 10000.

`pageSize` is out of range.

Set a value between `1` and `10000`, or remove the property.

Warning `Key column … value … is not unique: … ` in the logs.

`keyColumn` is not unique (wrong column, or duplicates in a view).

Use a unique key column, or fix the data. The warning does not show the key values. To find them, run:

SELECT <keyColumn>, COUNT() FROM <table> GROUP BY <keyColumn> HAVING COUNT() > 1;

Out of memory, or a very slow reconciliation, on a large table.

Pages too large, or no index on `keyColumn`.

Lower `pageSize`. Add an index on `keyColumn`.

Results are not in the requested order.

Search results always come in `keyColumn` order.

Expected behavior: see "Search: paging and order".