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 ( |
|
|
Supported databases |
PostgreSQL, Oracle, MySQL, Microsoft SQL Server |
|
Object classes |
|
|
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 |
|
Platform version |
|
Oracle |
|
|
|
MySQL |
|
|
|
Microsoft SQL Server |
|
|
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 |
|
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 |
|
Column name configured in |
|
Optional. The password is written as is (clear text). The connector does not hash it. |
|
Column configured in |
(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 |
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 example2024-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 |
|
|
Integer values |
A plain number, for example |
|
Multi-valued values ( |
Add the property several times (one value each), or give one value with commas: |
|
Secret values ( |
The value must be a secret URI: |
|
Value from a Setting |
For a non-secret property, you can use |
|
|
|
Minimal example (PostgreSQL)
{
"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 |
|---|---|---|---|---|---|
|
|
String |
Class name of the JDBC driver. See the table in section 1. |
Yes |
|
|
|
|
String |
JDBC connection URL. It can contain the placeholders |
Yes |
|
|
|
|
String |
Host name or IP address of the database server. Replaces |
Yes, if the URL contains |
– |
|
|
|
String |
TCP port of the database server. Replaces |
Yes, if the URL contains |
– |
|
|
|
String |
Database name (Oracle: SID or service name). Replaces |
Yes, if the URL contains |
– |
|
|
|
String |
Database account used by the connector. It needs |
Yes |
– |
|
|
|
String (secret) |
Password of the database account. Use a secret URI. |
Yes |
– |
|
|
|
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) |
|
|
|
int |
Timeout (seconds) of the driver's own connection check. Used only if |
No |
|
|
Table mapping
|
Property |
Type |
Description |
Mandatory |
Default Value |
Example |
|---|---|---|---|---|---|
|
|
String |
Name of the table (or view) that holds the accounts. You can add the schema: |
Yes |
– |
|
|
|
String |
Column that identifies a row. Mapped to |
Yes |
– |
|
|
|
String |
Column that holds the account password. Mapped to |
No |
– |
|
|
|
boolean |
If |
No |
|
|
|
|
String |
How column names are quoted in SQL. Values: |
No |
– ( |
|
|
|
boolean |
If |
No |
|
|
Data types
|
Property |
Type |
Description |
Mandatory |
Default Value |
Example |
|---|---|---|---|---|---|
|
|
boolean |
If |
No |
|
|
|
|
boolean |
If |
No |
|
|
Search
|
Property |
Type |
Description |
Mandatory |
Default Value |
Example |
|---|---|---|---|---|---|
|
|
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 |
|
|
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 |
|---|---|---|---|---|---|
|
|
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) |
|
|
|
String |
Column used to sort the Live Sync results ( |
No |
– ( |
|
|
|
Boolean |
Sort order of the Live Sync results: |
No |
|
|
Error handling
|
Property |
Type |
Description |
Mandatory |
Default Value |
Example |
|---|---|---|---|---|---|
|
|
boolean |
If |
No |
|
|
|
|
String |
Comma-separated list of texts. During a create, if the SQL error message contains one of them, the connector reports "already exists". |
No |
– |
|
|
|
boolean |
If |
No |
|
|
|
|
String[] |
SQLState codes that mean "already exists" (for example a unique constraint violation). |
No |
– |
|
|
|
String[] |
SQLState codes that mean "connection failed". |
No |
– |
|
|
|
String[] |
SQLState codes that mean "invalid attribute value". |
No |
– |
|
|
|
String[] |
SQLState codes that mean "configuration error". |
No |
– |
|
JDBC connection parameters by database
Summary
|
Database |
|
|
Default port |
Recommended |
Recommended data type option |
|
|---|---|---|---|---|---|---|
|
PostgreSQL |
|
|
|
|
|
|
|
Oracle |
|
Service name: |
|
|
|
|
|
MySQL |
|
|
|
|
– |
|
|
SQL Server |
|
|
|
|
– |
|
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¶m2=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 |
|---|---|---|---|---|
|
|
Turns on TLS. With |
|
|
|
|
|
TLS level. |
|
|
|
|
|
Class that creates TLS connections. |
Class name |
Driver internal factory (reads |
|
|
|
Timeout to open the TCP connection, in seconds. |
Integer |
|
|
|
|
Timeout for a read on the socket, in seconds. |
Integer |
|
|
|
|
Timeout to connect and log in, in seconds. |
Integer |
|
|
|
|
Sends TCP keep-alive packets. Helps when a firewall drops idle connections. |
|
|
|
|
|
Schema search path. Lets you write |
Schema name |
– |
|
|
|
Name shown in |
String |
|
|
|
|
Server type to use with a multi-host URL. |
|
|
|
Multi-host URL (failover): jdbc:postgresql://db1:5432,db2:5432/hr?targetServerType=primary
Oracle
URL formats:
|
Form |
URL |
Notes |
|---|---|---|
|
Service name |
|
Recommended. |
|
SID |
|
Old form (connector default). |
|
Easy Connect Plus (TLS and parameters) |
|
Use |
|
TNS descriptor |
|
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 |
|---|---|---|---|---|
|
|
With |
|
|
|
|
|
With |
DN |
– |
|
|
|
Timeout to open the connection, in seconds. |
Integer |
Driver default |
|
|
|
Timeout to open the TCP connection, in seconds. |
Integer |
Driver default |
|
|
|
Number of connection retries / delay between retries (seconds). |
Integer |
|
|
|
|
Timeout for a read on the socket, in milliseconds. |
Integer |
|
|
|
|
Timeout to open the connection, in milliseconds (same purpose as |
Integer |
Driver default |
|
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=trueif the table hasTIMESTAMPorDATEcolumns.
MySQL
URL format: jdbc:mysql://host:port/database?param1=value1¶m2=value2
Example:
jdbc:mysql://%h:%p/%d?sslMode=VERIFY_IDENTITY&connectTimeout=10000&socketTimeout=30000&connectionTimeZone=UTC
|
Parameter |
Description |
Values |
Default |
Example |
|---|---|---|---|---|
|
|
TLS level. |
|
|
|
|
|
Allowed TLS versions. |
Comma-separated list |
Driver default |
|
|
|
Timeout to open the connection, in milliseconds. |
Integer |
|
|
|
|
Timeout for a read on the socket, in milliseconds. |
Integer |
|
|
|
|
Sends TCP keep-alive packets. |
|
|
|
|
|
Time zone of the server, used to convert dates and timestamps (old name: |
Time zone ID, |
|
|
|
|
Character set of the connection. |
Java charset |
Server setting |
|
|
|
What to do with the date |
|
|
|
|
|
Lets the driver get the server RSA key for |
|
|
– |
MySQL notes:
-
Use
quoting=backif column names are reserved words or contain special characters. -
jdbcDrivermust becom.mysql.cj.jdbc.Driver. The old classorg.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 |
|---|---|---|---|---|
|
|
Database name. |
String |
User default database |
|
|
|
Turns on TLS. |
|
|
|
|
|
If |
|
|
|
|
|
Host name expected in the server certificate, when it differs from the URL host. |
Host name |
URL host |
|
|
|
Timeout to connect and log in, in seconds. |
Integer |
Driver default |
|
|
|
Timeout for a read on the socket, in milliseconds. |
Integer |
|
|
|
|
Timeout for a query, in seconds. |
Integer |
|
|
|
|
Named instance. Use it instead of the port (the SQL Browser service must be reachable). |
String |
– |
|
|
|
Name shown in the SQL Server sessions. |
String |
|
|
|
|
Faster failover for an Always On availability group listener. |
|
|
|
|
|
Authentication mode. Use |
|
|
|
|
|
If |
|
|
|
SQL Server notes:
-
Use
quoting=bracketsif column names are reserved words or contain spaces. -
Windows integrated authentication (
integratedSecurity=true) is not available in Memority.
Full configuration examples
PostgreSQL
|
Property |
Value |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Oracle
|
Property |
Value |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MySQL
|
Property |
Value |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQL Server
|
Property |
Value |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Live Sync: how it works and limits
-
The first sync token is the highest value of
changeLogColumnin 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 bysyncOrderColumn(orchangeLogColumn). -
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
changeLogColumnat 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 |
|---|---|---|
|
|
Wrong |
Use a driver class from section 1. |
|
The connector connects to Oracle by mistake, or fails with an Oracle URL. |
|
Set both properties. |
|
|
The URL contains |
Set the property, or remove the placeholder from the URL. |
|
|
Wrong table name, missing schema, or missing |
Check |
|
|
|
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: |
|
An attribute is not found on Oracle. |
Oracle returns uppercase column names. |
Use the uppercase name in the mapping ( |
|
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". |