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:
AuditLoggingComponent
,SecureConnectorExtension
,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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.odpi.openmetadata.frameworks.connectors.ConnectorBase
ConnectorBase.ProtectedConnection
-
Field Summary
Fields inherited from class org.odpi.openmetadata.frameworks.connectors.ConnectorBase
connectedAssetProperties, connectionBean, connectionProperties, connectorInstanceId, embeddedConnectors, messageFormatter, secretsStoreConnectorMap
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDatabaseDefinitions
(List<String> ddlStatements) Issue the supplied DDL statements.void
Free up any resources held since the connector is no longer needed.Return 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
(String tableName, String identifierColumnName, String identifierColumnValue, String timestampColumnName, Map<String, Integer> columnNameTypeMap) Retrieve the row with the requested identifier and with the latest timestamp.Retrieve the row that matches the where clause.Retrieve the row with the requested identifier and with the latest timestamp.getMatchingRows
(String sqlCommand, Map<String, Integer> columnNameTypeMap) Retrieve the row with the requested identifier and with the latest timestamp.Retrieve the row with the requested identifier and with the latest timestamp.void
insertRowIntoTable
(String tableName, Map<String, JDBCDataValue> columnNameValueMap) Prepare an INSERT SQL statement with all the columns for the new row filled out.void
insertRowsIntoTable
(String tableName, List<Map<String, JDBCDataValue>> rows) Prepare an INSERT SQL statement with all the columns for each of the new rows filled out.void
issueSQLCommand
(String sqlCommand) Issue a SQL command that expects no results.void
setAuditLog
(AuditLog auditLog) Receive an audit log object that can be used to record audit log messages.void
start()
Indicates that the connector is completely configured and can begin processing.Methods inherited from class org.odpi.openmetadata.frameworks.connectors.ConnectorBase
combineConfigurationProperties, disconnectConnectors, equals, getArrayConfigurationProperty, getAssetTypeName, getBooleanConfigurationProperty, getConnectedAssetProperties, getConnection, getConnectorInstanceId, getDateConfigurationProperty, getIntConfigurationProperty, getLongConfigurationProperty, getNetworkAddresses, getStringConfigurationProperty, getSuppliedPlaceholderProperties, hashCode, initialize, initializeConnectedAssetProperties, initializeEmbeddedConnectors, initializeSecretsStoreConnector, isActive, logExceptionRecord, logRecord, logRecord, throwMissingConfigurationProperty, throwMissingResource, throwNoAsset, throwWrongTypeOfAsset, throwWrongTypeOfResource, throwWrongTypeOfRootSchema, toString
Methods 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
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:
setAuditLog
in interfaceAuditLoggingComponent
- Parameters:
auditLog
- audit log object
-
getConnectorComponentDescription
Return the component description that is used by this connector in the audit log.- Specified by:
getConnectorComponentDescription
in interfaceAuditLoggingComponent
- Returns:
- id, name, description, wiki page URL.
-
start
Indicates that the connector is completely configured and can begin processing.- Overrides:
start
in classConnectorBase
- Throws:
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
-
addDatabaseDefinitions
Issue the supplied DDL statements.- Parameters:
ddlStatements
- statements to execute- Throws:
PropertyServerException
- problem communicating with the database
-
issueSQLCommand
Issue a SQL command that expects no results.- Parameters:
sqlCommand
- command to issue- Throws:
PropertyServerException
- something went wrong
-
getLatestRow
public Map<String,JDBCDataValue> getLatestRow(String tableName, String identifierColumnName, String identifierColumnValue, String timestampColumnName, Map<String, Integer> columnNameTypeMap) throws PropertyServerExceptionRetrieve the row with the requested identifier and with the latest timestamp.- Parameters:
tableName
- 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:
PropertyServerException
- there was a problem calling the database
-
getMatchingRow
public Map<String,JDBCDataValue> getMatchingRow(String tableName, String whereClause, Map<String, Integer> columnNameTypeMap) throws PropertyServerExceptionRetrieve the row that matches the where clause.- Parameters:
tableName
- name of the table to querywhereClause
- condition describing how to match the desired columnscolumnNameTypeMap
- map of resulting column names and values to include in the results- Returns:
- row consisting of column names to data values that represent the requested row
- Throws:
PropertyServerException
- there was a problem calling the database
-
getMatchingRows
public List<Map<String,JDBCDataValue>> getMatchingRows(String tableName, String whereClause, Map<String, Integer> columnNameTypeMap) throws PropertyServerExceptionRetrieve the row with the requested identifier and with the latest timestamp.- Parameters:
tableName
- name of the table to querywhereClause
- condition describing how to match the desired columnscolumnNameTypeMap
- map of resulting column names and values to include in the results- Returns:
- list of rows consisting of column names to data values that represent the requested row
- Throws:
PropertyServerException
- there was a problem calling the database
-
getMatchingRows
public List<Map<String,JDBCDataValue>> getMatchingRows(String sqlCommand, Map<String, Integer> columnNameTypeMap) throws PropertyServerExceptionRetrieve the row with the requested identifier and with the latest timestamp.- Parameters:
sqlCommand
- condition describing how to match the desired columnscolumnNameTypeMap
- map of resulting column names and values to include in the results- Returns:
- list of rows consisting of column names to data values that represent the requested row
- Throws:
PropertyServerException
- there was a problem calling the database
-
getRows
public List<Map<String,JDBCDataValue>> getRows(String tableName, Map<String, Integer> columnNameTypeMap) throws PropertyServerExceptionRetrieve the row with the requested identifier and with the latest timestamp.- Parameters:
tableName
- name of the table to querycolumnNameTypeMap
- map of resulting column names and values to include in the results- Returns:
- list of rows consisting of column names to data values that represent the requested row
- Throws:
PropertyServerException
- there was a problem calling the database
-
insertRowIntoTable
public void insertRowIntoTable(String tableName, Map<String, JDBCDataValue> columnNameValueMap) throws PropertyServerExceptionPrepare an INSERT SQL statement with all the columns for the new row filled out.- Parameters:
tableName
- name of the table where the row is to be addedcolumnNameValueMap
- column names, values and types- Throws:
PropertyServerException
- problem executing the command
-
insertRowsIntoTable
public void insertRowsIntoTable(String tableName, List<Map<String, JDBCDataValue>> rows) throws PropertyServerExceptionPrepare an INSERT SQL statement with all the columns for each of the new rows filled out.- Parameters:
tableName
- name of the table where the row is to be addedrows
- list of column names, values and types- Throws:
PropertyServerException
- problem executing the command
-
disconnect
Free up any resources held since the connector is no longer needed.- Overrides:
disconnect
in classConnectorBase
- Throws:
ConnectorCheckedException
- there is a problem within the connector.
-