title: How to fix: No suitable driver found for jdbc:sqlserver
body: <p>I am trying to connect to a MS SQL Server database running on the same machine as the application but I keep getting the error:</p>
  
  <blockquote>
    <p>No suitable driver found for
    jdbc:sqlserver://localhost:1433;database=SQLTEST;user=TEST;password=1234567890;encrypt=true;trustServerCertificate=false;loginTimeout=30;</p>
  </blockquote>
  
  <p>I am running MS SQL Server 2017 and JDK1.8.x.</p>
  
  <p>The first thing I did was creating a user in the following way in SSMS using T-SQL:</p>
  
  <pre><code>USE SQLTEST
  CREATE ROLE TEST
  GRANT SELECT, INSERT ON SCHEMA :: [dbo] TO TEST
  CREATE LOGIN TEST_LOGIN WITH PASSWORD = '1234567890'
  CREATE USER USER_TEST FROM LOGIN TEST_LOGIN
  ALTER ROLE TEST ADD MEMBER USER_TEST
  </code></pre>
  
  <p>I then used Maven to add the driver to my project in the pom.xml file:</p>
  
  <pre><code>&lt;!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc --&gt;
  &lt;dependency&gt;
       &lt;groupId&gt;com.microsoft.sqlserver&lt;/groupId&gt;
       &lt;artifactId&gt;mssql-jdbc&lt;/artifactId&gt;
       &lt;version&gt;7.2.2.jre8&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Followed by adding and altering the example code given by Microsoft (note that this should become a JAX-RS REST-API, that is why the annotations are there):</p>
  
  <pre><code>@Path("t2")
  public class T2 {
      @GET
      public String show() {
          String r = "";
          String connectionUrl =
                  "jdbc:sqlserver://localhost:1433;"
                          + "database=SQLTEST;"
                          + "user=TEST;"
                          + "password=1234567890;"
                          + "encrypt=true;"
                          + "trustServerCertificate=false;"
                          + "loginTimeout=30;";
  
          try (Connection connection = DriverManager.getConnection(connectionUrl);) {
              // Code here.
          }
          // Handle any errors that may have occurred.
          catch (SQLException e) {
              e.printStackTrace();
              r = e.getMessage();
          }
          return r;
      }
  }
  </code></pre>
  
  <p>Running this results in the error as given in the start of this post. Did I forget something or did I do something wrong?</p>