Setting Up Connectors
This topic describes how to set up connectors within Harness DB DevOps.
Setting Up Connectors for Databases
JDBC Connectors
The JDBC connector accepts the following:
- JDBC URL: The database URL (string)
- Username: Username (string / secret)
- Password: Password (secret)
It performs a test connection using a delegate with a delegate selector or any available delegate. Ensure the delegate has network access to the database.
The JDBC connector is used for connecting to your database instance.
URL Examples
| Database | JDBC URL Format |
|---|---|
| ORACLE | jdbc:oracle:thin:@//{host}:{port}/{servicename} |
| POSTGRES | jdbc:postgresql://{host}:{port}/{dbName}?sslmode=disable |
| COCKROACHDB | jdbc:postgresql://{host}:{port}/{dbName} |
| SQLSERVER | jdbc:sqlserver://{host}:{port};trustServerCertificate=true;databaseName={dbName} |
| MYSQL | jdbc:mysql://{host}:{port}/{dbName} |
| MONGODB | mongodb://{host}:{port}/{dbName}?authSource=admin |
| MongoDB Atlas | mongodb+srv://{username}:{password}@{cluster}/{dbName}?authSource=admin |
| GOOGLE SPANNER | jdbc:cloudspanner:/projects/{project-id}/instances/{instance-id}/databases/{database-name}?lenient=true |
| GOOGLE ALLOYDB | jdbc:postgresql://{host}:{port}/{dbName} |
| SNOWFLAKE | jdbc:snowflake://{host}/?warehouse={wh}&db={dbName}&schema={dbSchema}&role={authRole} |
| MongoDB SSL | mongodb://{host}:{port}/{dbName}?tls=true&authSource=admin |
| POSTGRES SSL | jdbc:postgresql://{host}:{port}/{dbName}?ssl=true |
| SQLSERVER SSL | jdbc:sqlserver://{host}:{port};databaseName={dbName};encrypt=true;trustServerCertificate=false; |
| MYSQL SSL | jdbc:mysql://{host}:{port}/{dbName}?useSSL=true |
| ORACLE SSL | jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST={host})(PORT={port}))(CONNECT_DATA=(SERVICE_NAME={servicename}))) |
| COCKROACHDB SSL | jdbc:postgresql://{host}:{port}/{dbName}?sslmode=require |
Setting Up MongoDB
MongoDB connections in Harness DB DevOps support both self-hosted and cloud-based MongoDB instances.
Prerequisites for MongoDB
-
Connection Format:
- Use
mongodb+srv://for MongoDB Atlas and cloud instances. - Use
mongodb://for self-hosted instances.
- Use
-
Authentication:
- Username/Password: Database user credentials
- authSource: Must be specified (typically
admin) - Database: Target database name must be included in the URL
-
Network Access:
- Ensure the delegate has network connectivity to the MongoDB cluster
- For MongoDB Atlas, whitelist the delegate's IP address
MongoDB URL Requirements
- The connection string must include
+srvfor cloud instances - The target
databasemust be specified in the URL path - The database user must have appropriate read/write permissions on the target database
Setting Up Google Spanner
Google Spanner uses a unique JDBC URL format and does not require a password for authentication. Instead, authentication is handled via Service Account (SA) credentials.
Prerequisites for Google Spanner
- Authentication:
- Google Service Account (GSA) json key
- The GSA must have the following roles:
roles/spanner.databaseAdminroles/spanner.databaseUser
Setting Up AlloyDB
AlloyDB connections in Harness DB DevOps require a Host, Port, and Database. The username and password are also required for authentication.
Prerequisites for AlloyDB
- Connection Format:
- Use
jdbc:postgresql://{HOST}:{PORT}/{DBNAME}for AlloyDB instances.
- Use
- Authentication:
- Username/Password: Database user credentials
- Network Access:
- Ensure the Harness Delegate has network connectivity to the AlloyDB instance. (Both are in same VPC, which is also default behavior in GCP).
Setting Up Snowflake
Snowflake connections in Harness DB DevOps require a specific JDBC URL format that includes the account identifier, warehouse, database, schema, and role. If the role is not specified, the default role for the user will be used. Either username/password or PKI authentication can be used to authenticate to Snowflake.
Prerequisites for Snowflake
To connect to Snowflake, you need to provide the following information:
- Username and Password: Provide the Snowflake username and password as secrets in the JDBC connector configuration.
- PKI Authentication: Use Public Key Infrastructure (PKI) authentication by providing the username, private key file reference, and an optional private key passphrase reference while configuring the JDBC connector.
The private key file reference is a secret file, and the passphrase reference is a secret text. If your private key is encrypted, you can provide the passphrase to decrypt it. For example:
"username": "john_doe",
"privateKeyFileRef": "snowflake-trial-private-key",
"privateKeyPassphraseRef": "snowflake-trial-passphrase"
Connector FAQs
Why can't I connect to my Oracle database with a sys as sysdba username?
Sometimes, users want to login to their database using the sys as sysdba username. To do so properly with Harness:
- Your JDBC URL should have the query parameter
internal_logon=sysdba - Your Username should be
sys.
Go to Oracle's documentation for information about logging on as sys.