JDBC Driver for Microsoft Dynamics CRM

Build 22.0.8462

Establishing a Connection

Creating a JDBC Data Source

You can create a JDBC data source to connect from your Java application. Creating a JDBC data source based on the CData JDBC Driver for Microsoft Dynamics CRM consists of three basic steps:

  • Add the driver JAR file to the classpath. The JAR file is located in the lib subfolder of the installation directory. Note that the .lic file must be located in the same folder as the JAR file.
  • Provide the driver class. For example:
    cdata.jdbc.dynamicscrm.DynamicsCRMDriver
  • Provide the JDBC URL. For example:
    jdbc:dynamicscrm:User=myuseraccount;Password=mypassword;URL=https://myOrg.crm.dynamics.com/;CRM Version=CRM Online;
    
    or
    
    jdbc:cdata:dynamicscrm:User=myuseraccount;Password=mypassword;URL=https://myOrg.crm.dynamics.com/;CRM Version=CRM Online;

    The second format above can be used whenever there is a conflict in your application between drivers using the same URL format to ensure you are using the CData driver. The URL must start with either "jdbc:dynamicscrm:" or "jdbc:cdata:dynamicscrm:" and can include any of the connection properties in name-value pairs separated with semicolons.

Connecting to Microsoft Dynamics CRM

To connect, set Url to the root URL of your organization and set User, Password, and CRMVersion.

Authenticating to CRM On-Premises

Additionally for CRM on-premises, select an authentication method. By default, the driver uses Windows (NTLM) authentication. To use another authentication type, such as Kerberos delegation, set AuthScheme. The following is an example connection string:

AuthScheme=Auto;Url=https://myOrg.crm.dynamics.com/;User=username;Password=password;CRM Version='CRM2011+'"

Internet Facing Deployments

For Dynamics CRM with IFD, set InternetFacingDeployment to true. The following is an example connection string:

AuthScheme=Auto;Url=https://myOrg.crm.dynamics.com/;User=username;Password=password;InternetFacingDeployment=True;CRM Version='CRM2011+'"

AzureAD

Microsoft Dynamics CRM supports AzureAD. To authenticate using AzureAD, you must create a custom app to obtain the OAuthClientId, OAuthClientSecret to use custom AzureAD credentials. In addition to those properties, set CallbackURL.

You should set the AuthScheme to OAuth to enforce the OAuth Authentication scheme.

After creating your OAuth Application, set the following connection properties:

  • AuthScheme: Set to OAuth.
  • OAuthClientId: Set to the consumer key in your app settings.
  • OAuthClientSecret(optional): Set to the consumer secret in your app settings.
  • ADFSServer: Set to the ADFS server in your deployment.

When you connect, the driver opens the AzureAD endpoint in your default browser. Log in and grant permissions to the application. The driver then completes the following AzureAD process:

  1. Gets the callback URL and sets the access token and ADFSServer to authenticate requests.
  2. Saves OAuth values in your connection settings. These values persist across connections.
  3. Exchanges the returned refresh token for a new, valid access token.
The following is an example connection string for Internet Facing Deployments:
AuthScheme=OAuth;Url=https://myOrg.crm.dynamics.com/;CRM Version=CRM2011+;InitiateOAuth=GETANDREFRESH;CallbackUrl=http://localhost:33333;OAuthClientId=ClientID;ADFSServer=https://auth.adfs.com/;"
The following is an example connection string for Online Instance:
AuthScheme=OAuth;Url=https://myOrg.crm.dynamics.com/;CRM Version=CRMOnline;InitiateOAuth=GETANDREFRESH;CallbackUrl=http://localhost:33333;OAuthClientId=ClientID;AzureTenant=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx;"

Kerberos

Please see Using Kerberos for details on how to authenticate with Kerberos

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8462