Search code examples
sql-serverazure-sql-databasessmsdatagrip

Can't connect to Azure SQL Database in Jetbrains Datagrip but it works in SMSS


I'm trying to connect to an Azure SQL database using Datagrip (I'm on Linux) but am receiving a connection error. I tried installing Microsoft SQL Server Management Studio (SMSS) on a Windows machine and it worked fine.

This is a screenshot of the SMSS connection properties:

SMSS connection properties

And here is a screenshot of the Datagrip connection properties:

enter image description here

Any idea what I am doing wrong here?


Solution

  • This error is caused if the Server name from the connection string does not match with the server name in the TLS certificate while validating.

    When encrypt is set to true and trustServerCertificate is set to false, JDBC driver will validate the TLS certificate to ensure it is connecting to the correct server.

    When ‘trustServerCertificate’ is set to true, JDBC driver will not validate in TLS certificate.

    1. Get the JDBC Connection string from the portal.

    enter image description here

    1. Search for ‘trustServerCertificate’ and set it to “true”.

      jdbc:sqlserver://{your_servername}.database.windows.net:1433;database={your_databasename};user={your_username}@{your_servername};password={your_password_here};encrypt=true;trustServerCertificate=true;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
      

    enter image description here