Integrate Connection and Credentials with Datasource with JDBC Connection

Vinodh121
Tera Contributor

I Have a Data source to connect to Snowflake via JDBC Connectivity, 

instead of configuring username/password directly in datasource, i want to use "connection and credentials alias"

how to achieve this, can someone help?

4 REPLIES 4

RajarathinaP
Tera Contributor

Hello @Vinodh121 I have the same problem. Did You find a solution for this?

AJ-TechTrek
Giga Sage
Giga Sage

Hi @Vinodh121 ,

 

As per my Understanding ,that will be proabale solution 

 

Here how you can securely connect your ServiceNow data source to Snowflake without hardcoding username/password, by using Connection & Credential Alias (CCA):

 

Step-by-step solution:


1. Create a Credential in ServiceNow:
* Go to Connections & Credentials > Credentials.
* Create a new credential record:
* Type: Username & Password (for Snowflake, typically).
* Enter your Snowflake username and password.

 

2. Create a Connection Alias:
* Go to Connections & Credentials > Connection & Credential Aliases.
* Create a new Alias:
* Name it something like Snowflake_JDBC_Alias.
* For Credential field: select the credential you created above.
* Connection info: you can optionally store connection-specific data (e.g., JDBC URL).

 

3. Configure the Data Source to use the Alias:
* Go to your Data Source record (System Import Sets > Administration > Data Sources).
* In the Data Source form:
* Find the field Connection & Credential Alias (sometimes hidden under “Advanced view”).
* Select the Snowflake_JDBC_Alias you created.
This tells ServiceNow to dynamically use the credential stored in the alias when connecting via JDBC, instead of a hardcoded username/password.

 

4. Test the Connection:
* Use the Test Load or Load All Records option on the data source to verify that ServiceNow can successfully connect to Snowflake using the alias.

 

Why this is better:
* Credentials are stored securely in the ServiceNow Credential table, encrypted at rest.
* It centralizes credential management — no hardcoded passwords in the Data Source config.
* Easier to rotate credentials: update them in one place without touching multiple data sources.

 

Tip:
* Make sure the user/role you configure has the right Snowflake access.
* The MID Server (if used) also needs permission to use the credential alias.

 

Please appreciate the efforts of community contributors by marking appropriate response as Mark my Answer Helpful or Accept Solution this may help other community users to follow correct solution in future.
 

Thank You
AJ - TechTrek with AJ - ITOM Trainer
LinkedIn:- https://www.linkedin.com/in/ajay-kumar-66a91385/
YouTube:- https://www.youtube.com/@learnitomwithaj
Topmate:- https://topmate.io/aj_techtrekwithaj (Connect for 1-1 Session)
ServiceNow Community MVP 2025

Hello @AJ-TechTrek 

 

If I am using private key for authentication, I am having trouble generating the connection url. I use the below Connection string.

jdbc❄️//<accountname>.snowflakecomputing.com/?private_key_file=
<path to private key>&user=<username>&warehouse=WH&db=DB&schema=SCH

 

Let me know if you can help.

AJ-TechTrek
Giga Sage
Giga Sage

Hi @RajarathinaP ,

 

As per my Understanding Problem statement is this -

 

You’re trying to connect from ServiceNow (probably using JDBC Data Source or MID Server JDBC connection) to Snowflake using a private key.



Your connection string looks like this:

 

jdbc❄️//<accountname>.snowflakecomputing.com/?private_key_file=<path to private key>&user=<username>&warehouse=WH&db=DB&schema=SCH


But it's not working as expected.


1. Use the correct Snowflake JDBC URL format

 


Snowflake JDBC driver expects the private key to be configured in the JVM (via connection properties or via a PKCS8 key),



not directly in the URL.

 

The typical Snowflake JDBC URL looks like:

jdbc❄️//.snowflakecomputing.com/?user=&warehouse=&db=&schema=&role=

 

2. How to handle the private key in ServiceNow (MID Server)


Snowflake JDBC does not read private_key_file from URL.
Instead:


* Convert your private key to unencrypted PKCS8 format.


* Set these as connection properties (not in the URL):


Property and value will be like that


privateKey -    File Full path to PKCS8 private key file
privateKeyFilePwd -   Password (if the private key is encrypted; usually keep it unencrypted for service accounts)
user -                        Username

 

3. In ServiceNow Data Source / JDBC connection:
ServiceNow JDBC data source doesn't directly support passing local file paths like privateKeyFile.


So you have two better approaches

 

Recommended:


* Use a JDBC connection via MID Server where the MID Server’s Java keystore has the private key loaded.
* Configure connection properties in the MID Server Java environment (e.g., snowflake.properties file or via Java system properties).

 

OR

 

Alternate:
* Instead of key file, use the raw private key content loaded into the connection properties from secure properties.

 

4. Example proper JDBC URL:
jdbc❄️//.snowflakecomputing.com/?user=&warehouse=WH&db=DB&schema=SCH

 

And separately set:

 

connectionProperties.put("privateKey", <PrivateKeyObject>)
In ServiceNow, if you use JDBC data source through MID Server:
* Put private key into the MID Server keystore, and reference it as a Java PrivateKey object.
* The ServiceNow platform itself doesn't support private_key_file in JDBC URL.

 

5. Practical summary:
* The JDBC URL should not include private_key_file.
* The private key must be passed as a Java PrivateKey object, usually configured in code or loaded by the driver.
*With ServiceNow:
A.Use MID Server to run the JDBC connection.
B. Place the private key in a secure location on the MID Server.
C. Modify the JDBC connection to use the private key (this may require a custom script include or integration, as standard JDBC data source doesn't support file-based key reference).

 

Please appreciate the efforts of community contributors by marking appropriate response as Mark my Answer Helpful or Accept Solution this may help other community users to follow correct solution in future.
 

Thank You
AJ - TechTrek with AJ - ITOM Trainer
LinkedIn:- https://www.linkedin.com/in/ajay-kumar-66a91385/
YouTube:- https://www.youtube.com/@learnitomwithaj
Topmate:- https://topmate.io/aj_techtrekwithaj (Connect for 1-1 Session)
ServiceNow Community MVP 2025