Class JDBCResourceConnector
java.lang.Object
org.odpi.openmetadata.frameworks.connectors.Connector
org.odpi.openmetadata.frameworks.connectors.ConnectorBase
org.odpi.openmetadata.adapters.connectors.resource.jdbc.JDBCResourceConnector
- All Implemented Interfaces:
org.odpi.openmetadata.frameworks.auditlog.AuditLoggingComponent,org.odpi.openmetadata.frameworks.connectors.SecureConnectorExtension,org.odpi.openmetadata.frameworks.connectors.VirtualConnectorExtension
public class JDBCResourceConnector
extends org.odpi.openmetadata.frameworks.connectors.ConnectorBase
implements org.odpi.openmetadata.frameworks.auditlog.AuditLoggingComponent, org.odpi.openmetadata.frameworks.connectors.VirtualConnectorExtension
JDBCResourceConnector provides basic implementation of
The DataSource can be used directly. There are also selected methods to issue common SQL statements to the database.
DataSource interface in order to get a Connection to
target database. This is done via a static inner class, since DataSource.getConnection() clashes with
ConnectorBase.getConnection().
The DataSource can be used directly. There are also selected methods to issue common SQL statements to the database.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidFree up any resources held since the connector is no longer needed.org.odpi.openmetadata.frameworks.auditlog.ComponentDescriptionReturn the component description that is used by this connector in the audit log.Return the name of the database.Return the DataSource implementation for this database.getLatestRow(Connection jdbcConnection, String tableName, String identifierColumnName, String identifierColumnValue, String timestampColumnName, Map<String, Integer> columnNameTypeMap) Retrieve the row with the requested identifier and with the latest timestamp.voidinitializeEmbeddedConnectors(List<org.odpi.openmetadata.frameworks.connectors.Connector> embeddedConnectors) Set up the list of connectors that this virtual connector will use to support its interface.voidinsertRowIntoTable(Connection jdbcConnection, String tableName, Map<String, JDBCDataValue> columnNameValueMap) Prepare an INSERT SQL statement with all the columns for the new row filled out.voidsetAuditLog(org.odpi.openmetadata.frameworks.auditlog.AuditLog auditLog) Receive an audit log object that can be used to record audit log messages.voidstart()Indicates that the connector is completely configured and can begin processing.Methods inherited from class org.odpi.openmetadata.frameworks.connectors.ConnectorBase
equals, getConnectedAssetProperties, getConnection, getConnectorInstanceId, hashCode, initialize, initializeConnectedAssetProperties, initializeSecretsStoreConnector, isActive, toStringMethods inherited from class org.odpi.openmetadata.frameworks.connectors.Connector
clearStatisticProperty, clearStatisticTimestamp, getConnectorStatistics, getStatisticCounter, getStatisticProperty, getStatisticTimestamp, incrementStatisticCounter, initializeStatisticCounter, setStatisticProperty, setStatisticTimestamp
-
Constructor Details
-
JDBCResourceConnector
public JDBCResourceConnector()
-
-
Method Details
-
setAuditLog
public void setAuditLog(org.odpi.openmetadata.frameworks.auditlog.AuditLog auditLog) Receive an audit log object that can be used to record audit log messages. The caller has initialized it with the correct component description and log destinations.- Specified by:
setAuditLogin interfaceorg.odpi.openmetadata.frameworks.auditlog.AuditLoggingComponent- Parameters:
auditLog- audit log object
-
getConnectorComponentDescription
public org.odpi.openmetadata.frameworks.auditlog.ComponentDescription getConnectorComponentDescription()Return the component description that is used by this connector in the audit log.- Specified by:
getConnectorComponentDescriptionin interfaceorg.odpi.openmetadata.frameworks.auditlog.AuditLoggingComponent- Returns:
- id, name, description, wiki page URL.
-
initializeEmbeddedConnectors
public void initializeEmbeddedConnectors(List<org.odpi.openmetadata.frameworks.connectors.Connector> embeddedConnectors) Set up the list of connectors that this virtual connector will use to support its interface. The connectors are initialized waiting to start. When start() is called on the virtual connector, it needs to pass start() to each of the embedded connectors. Similarly for disconnect().- Specified by:
initializeEmbeddedConnectorsin interfaceorg.odpi.openmetadata.frameworks.connectors.VirtualConnectorExtension- Parameters:
embeddedConnectors- list of connectors
-
start
public void start() throws org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedExceptionIndicates that the connector is completely configured and can begin processing.- Overrides:
startin classorg.odpi.openmetadata.frameworks.connectors.ConnectorBase- Throws:
org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException- there is a problem within the connector.
-
getDatabaseName
Return the name of the database.- Returns:
- string name
-
getDataSource
Return the DataSource implementation for this database. This supports creating the connection to the database.- Returns:
- DataSource
-
getLatestRow
public Map<String,JDBCDataValue> getLatestRow(Connection jdbcConnection, String tableName, String identifierColumnName, String identifierColumnValue, String timestampColumnName, Map<String, Integer> columnNameTypeMap) throws SQLExceptionRetrieve the row with the requested identifier and with the latest timestamp.- Parameters:
jdbcConnection- connection to the databasetableName- name of the table to queryidentifierColumnName- name of the column with the identifier in itidentifierColumnValue- value of the identifier to match ontimestampColumnName- name of the column with the timestampcolumnNameTypeMap- map of resulting column names and values to include in the results- Returns:
- Map of column names to data values that represent the requested row
- Throws:
SQLException- there was a problem calling the database
-
insertRowIntoTable
public void insertRowIntoTable(Connection jdbcConnection, String tableName, Map<String, JDBCDataValue> columnNameValueMap) throws SQLExceptionPrepare an INSERT SQL statement with all the columns for the new row filled out.- Parameters:
jdbcConnection- connection to send the requesttableName- name of the table where the row is to be addedcolumnNameValueMap- column names, values and types- Throws:
SQLException- problem executing the command
-
disconnect
public void disconnect() throws org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedExceptionFree up any resources held since the connector is no longer needed.- Overrides:
disconnectin classorg.odpi.openmetadata.frameworks.connectors.ConnectorBase- Throws:
org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException- there is a problem within the connector.
-