One way to connect to a service is through the JDBC DriverManager using the DriverManager.getConnection() method. As the following examples show, this method specifies a string containing a connection URL.

NTLM authentication

Connection conn = DriverManager.getConnection
  ("jdbc:datadirect:dynamics365:
    ServiceURL=http://mycompany.sso3.dynamics365.net/api/data/;
    AuthenticationMethod=NTLM;NTLMDomain=sso3;User=jsmith;Password=secret;");
Note: See NTLM authentication for details.

OAuth 2.0 refresh token grant

Connection conn = DriverManager.getConnection
  ("jdbc:datadirect:dynamics365:
    ServiceURL=https://mycompany.365.dynamics.net/api/data/;
    AuthenticationMethod=OAuth2;ClientID=29453d6f-6789-25gh-gd8g-44tk3c527831;
    ClientSecret=12a3=bCD/EfGh4Ijk+Lm5P67qR8s=//TuV+WXy1Zabcd;
    TokenURI=https://login.microsoftonline.com/ab123c45-def6-7g89-gh1i-m2345
       no67891/oauth2/token;
    RefreshToken=12a3=bCD/EfGh4Ijk+Lgd8g-44tk3c527831;");
Note: See OAuth 2.0 authentication for details on this and other supported grant types.