Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JDBC connectors #7819

Merged
merged 2 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ dependencies {
implementation project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:basic-file-connector')
implementation project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:csv-file-connector')
implementation project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:data-folder-connector')
implementation project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:jdbc-resource-connector')
implementation project(':open-metadata-implementation:adapters:open-connectors:configuration-store-connectors:configuration-encrypted-file-store-connector')
implementation project(':open-metadata-implementation:adapters:open-connectors:configuration-store-connectors:configuration-file-store-connector')
implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:files-integration-connectors')
implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:kafka-integration-connector')
implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:atlas-integration-connector')
implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:jdbc-integration-connector')
implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openapi-integration-connector')
implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openlineage-integration-connectors')
implementation project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:elasticsearch-integration-connector')
Expand Down Expand Up @@ -134,13 +136,15 @@ distributions {
from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:basic-file-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:csv-file-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:data-folder-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:jdbc-resource-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:configuration-store-connectors:configuration-encrypted-file-store-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:configuration-store-connectors:configuration-file-store-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:discovery-service-connectors').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:dynamic-archiver-connectors').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:governance-action-connectors').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:files-integration-connectors').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:atlas-integration-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:jdbc-integration-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:kafka-integration-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openapi-integration-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openlineage-integration-connectors').jar }
Expand Down Expand Up @@ -177,6 +181,7 @@ distributions {
from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:basic-file-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:csv-file-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:file-connectors:data-folder-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:jdbc-resource-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:configuration-store-connectors:configuration-encrypted-file-store-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:configuration-store-connectors:configuration-file-store-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:discovery-service-connectors').jar }
Expand All @@ -185,6 +190,7 @@ distributions {
from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:files-integration-connectors').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:atlas-integration-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:kafka-integration-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:jdbc-integration-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openapi-integration-connector').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:openlineage-integration-connectors').jar }
from { project(':open-metadata-implementation:adapters:open-connectors:integration-connectors:elasticsearch-integration-connector').jar }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@

# Data Store Connectors

The Data Store Connectors module contains
a small collection of connectors for applications.
The aim is to eventually cover most common types of data sources.
connectors to different types of data stores. These connectors implement the
The Data Store Connectors module contains a small collection of
[resource connectors](https://egeria-project.org/concepts/digital-resource-connector/) for accessing the most common types of data sources.

[Open Connector Framework (OCF)](../../../frameworks/open-connector-framework) **Connector** interface.

* **[file-connectors](file-connectors)** provides connector to read files.


There is a code sample that shows how to work with the file connector
* **[file-connectors](file-connectors)** provides connector to read files. There is a code sample that shows how to work with the file connector
in the [asset-management-samples](../../../../open-metadata-resources/open-metadata-samples/access-services-samples/asset-management-samples).
* **[jdbc-resource-connector](jdbc-resource-connector)** provides access to a JDBC resource through a connector.

----
* Return to [open-connectors](..) module.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the ODPi Egeria project. -->

# JDBC Resource Connector

Provides a basic implementation of the interface javax.sql.DataSource interface in order to establish a connection to target database. Because of a method clash, the interface has been implemented as an inner class of the connector and to get the implementation, one must call:
```
jdbcConnector.asDataSource()
```

See [JDBC Integration Connector](../jdbc-integration-connector/README.MD) for actual usage example.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Contributors to the ODPi Egeria project.
*/

// Artifact names are taken from the directory by default, set in settings.gradle to override
// The 'name' for the maven artifact, and description are set here
description = 'JDBC Resource Connector for Egeria'

dependencies {
compileOnly 'org.slf4j:slf4j-api'
compileOnly 'com.fasterxml.jackson.core:jackson-annotations'
compileOnly project(':open-metadata-implementation:frameworks:audit-log-framework')
compileOnly project(':open-metadata-implementation:frameworks:open-connector-framework')
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* SPDX-License-Identifier: Apache-2.0 */
/* Copyright Contributors to the ODPi Egeria project. */

package org.odpi.openmetadata.adapters.connectors.resource.jdbc;

import org.odpi.openmetadata.frameworks.connectors.ConnectorBase;

import javax.sql.DataSource;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;

/**
* JDBCResourceConnector provides basic implementation of {@link DataSource} interface in order to get a {@link Connection} to
* target database. This is done via a static inner class, since {@link DataSource#getConnection()} clashes with
* {@link ConnectorBase#getConnection()}
*/
public class JDBCResourceConnector extends ConnectorBase {

/**
* Get as {@link DataSource}
*
* @return implementation
*/
public DataSource asDataSource(){
return new JdbcConnectorAsDataSource();
}

private class JdbcConnectorAsDataSource implements DataSource {

@Override
public Connection getConnection() throws SQLException {
return DriverManager.getConnection(connectionBean.getEndpoint().getAddress(), connectionBean.getUserId(),
connectionBean.getClearPassword());
}

@Override
public Connection getConnection(String username, String password) throws SQLException {
return DriverManager.getConnection(connectionBean.getEndpoint().getAddress(), username, password);
}

@Override
public PrintWriter getLogWriter() throws SQLException {
return null;
}

@Override
public void setLogWriter(PrintWriter out) throws SQLException {

}

@Override
public void setLoginTimeout(int seconds) throws SQLException {

}

@Override
public int getLoginTimeout() throws SQLException {
return 0;
}

@Override
public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
return null;
}

@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
return null;
}

@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* SPDX-License-Identifier: Apache-2.0 */
/* Copyright Contributors to the ODPi Egeria project. */

package org.odpi.openmetadata.adapters.connectors.resource.jdbc;

import org.odpi.openmetadata.frameworks.connectors.ConnectorProviderBase;
import org.odpi.openmetadata.frameworks.connectors.properties.beans.ConnectorType;

import javax.sql.DataSource;

/**
* JDBCResourceConnectorProvider is the OCF connector provider for the jdbc resource connector.
*/
public class JDBCResourceConnectorProvider extends ConnectorProviderBase
{
static final String connectorTypeGUID = "64463b01-92f6-4d7b-9737-f1d20b2654f4";
static final String connectorQualifiedName = "Egeria::RelationalDbConnectors::Jdbc";
static final String connectorDisplayName = "Relational Database JDBC Connector";
static final String connectorTypeDescription = "Connector supports reading of metadata from relational databases using exclusively the JDBC API";

private static final String assetTypeName = "Database";

/**
* Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific
* registry store implementation.
*/
public JDBCResourceConnectorProvider() {
super();
super.setConnectorClassName(JDBCResourceConnector.class.getName());

ConnectorType connectorType = new ConnectorType();
connectorType.setType(ConnectorType.getConnectorTypeType());
connectorType.setGUID(connectorTypeGUID);
connectorType.setQualifiedName(connectorQualifiedName);
connectorType.setDisplayName(connectorDisplayName);
connectorType.setDescription(connectorTypeDescription);
connectorType.setSupportedAssetTypeName(assetTypeName);
connectorType.setConnectorProviderClassName(this.getClass().getName());

connectorInterfaces.add(DataSource.class.getName());
connectorType.setConnectorInterfaces(connectorInterfaces);

super.connectorTypeBean = connectorType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the ODPi Egeria project. -->

# JDBC Integration Connector

Catalogs a database via JDBC, extracting catalogs, schemas and the following table types: "TABLE", "VIEW", "FOREIGN TABLE" and "MATERIALIZED VIEW".
It will mark the primary key columns and extract the foreign key relationships.


### Configuration

For more details regarding bellow request, visit [Egeria documentation site](https://egeria-project.org/guides/admin/servers/configuring-an-integration-daemon/#configure-the-integration-services)

In addition, the integration connector uses an EmbeddedConnection in order to make use of the [JDBC resource connector](https://egeria-project.org/connectors/#databases), which keeps the connection details to target database
```
POST {{baseURL}}/open-metadata/admin-services/users/{{user}}/servers/{{server}}/integration-services/{{integrationServiceURLMarker}}
```
Body
```
{
"class": "IntegrationServiceRequestBody",
"omagserverPlatformRootURL": "<access-service-omag-url>",
"omagserverName": "<omas-server-name>",
"integrationConnectorConfigs":[
{
"class": "IntegrationConnectorConfig",
"connectorName": "<connector-name>",
"connection":{
"class": "VirtualConnection",
"connectorType" : {
"class": "ConnectorType",
"connectorProviderClassName": "org.odpi.openmetadata.adapters.connectors.integration.jdbc.JDBCIntegrationConnectorProvider"
},
"embeddedConnections":[
{
"class" : "EmbeddedConnection",
"embeddedConnection" : {
"class" : "Connection",
"userId" : "<user>",
"clearPassword" : "<password>",
"connectorType" : {
"class": "ConnectorType",
"connectorProviderClassName": "org.odpi.openmetadata.adapters.connectors.resource.jdbc.JDBCResourceConnectorProvider"
},
"endpoint":{
"class": "Endpoint",
"address" : "<jdbc-format-database-address>"
}
}
}
],
"configurationProperties": {
"includeSchemaNames": [],
"excludeSchemaNames": [],
"includeTableNames": [],
"excludeTableNames": [],
"includeViewNames": [],
"excludeViewNames": [],
"includeColumnNames": [],
"excludeColumnNames": []
}
},
"metadataSourceQualifiedName": "Source",
"refreshTimeInterval": "60",
"usesBlockingCalls": "false",
"permittedSynchronization": "FROM_THIRD_PARTY"
}
]
}
```

**access-service-omag-url** - url of omag server that hosts the paired access service

**omas-server-name** - name of paired access server

**connector-name** - this connectors name

**user** - database user

**password** - database password

**jdbc-format-database-address** - database address

**include/exclude** properties - control which schemas, tables, views and columns, respectively, are imported
if include is set, then the import is restricted to specified entities;
if exclude is set, the import will ignore specified entities;
if both are set, the import will take into account only the property include;

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Contributors to the ODPi Egeria project.
*/

// Artifact names are taken from the directory by default, set in settings.gradle to override
// The 'name' for the maven artifact, and description are set here

description = 'Egeria integration connector that uses Generic JDBC resource connector to access the database metadata'

dependencies {
compileOnly 'org.slf4j:slf4j-api'
compileOnly project(':open-metadata-implementation:frameworks:audit-log-framework')
compileOnly project(':open-metadata-implementation:frameworks:open-connector-framework')
compileOnly project(':open-metadata-implementation:frameworks:governance-action-framework')
compileOnly project(':open-metadata-implementation:frameworks:open-integration-framework')
compileOnly project(':open-metadata-implementation:access-services:data-manager:data-manager-api')
compileOnly project(':open-metadata-implementation:integration-services:database-integrator:database-integrator-api')
compileOnly project(':open-metadata-implementation:repository-services:repository-services-apis')
compileOnly project(':open-metadata-implementation:adapters:open-connectors:data-store-connectors:jdbc-resource-connector')

compileOnly 'org.apache.commons:commons-lang3'
compileOnly 'org.apache.commons:commons-collections4'
compileOnly 'com.fasterxml.jackson.core:jackson-annotations'
}

Loading
Loading