title: ClassNotFoundException - com.microsoft.jdbc.sqlserver.SQLServerDriver
body: <p>I have a web development project using local install of <code>Tomcat 7</code>.  I am trying to connect to <code>SQL Server 2012</code> using Microsoft's driver for jdbc (<code>sqljdbc41.jar</code>).</p>
  
  <p>The <code>sqljdbc41.jar</code> is in my application build path:</p>
  
  <p><a href="https://i.stack.imgur.com/yJfnP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yJfnP.png" alt="enter image description here"></a></p>
  
  <p>and I am exporting it.  Furthermore, in the Tomcat application directory <code>lib</code> folder I have also placed a copy of <code>sqljdbc41.jar</code>.</p>
  
  <p>There are no compile errors, but at runtime when I try to load the SQL Server driver I get the following:</p>
  
  <pre><code>ClassNotFoundException - com.microsoft.jdbc.sqlserver.SQLServerDriver
  </code></pre>
  
  <p>The exception is thrown in the following code block:</p>
  
  <pre><code>Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  String connectionUrl = "jdbc:sqlserver://"+server+":1433;databaseName="+database+";user=sa;password="+password+";";
  con = (Connection) DriverManager.getConnection(connectionUrl);
  </code></pre>
  
  <p>I have seen many posts on this topic without resolution:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/12461040/java-lang-classnotfoundexception-com-microsoft-jdbc-sqlserver-sqlserverdriver">java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver : Am I loading the right driver?</a></li>
  <li><a href="https://social.msdn.microsoft.com/Forums/sqlserver/en-US/b425c201-9882-4a48-b049-4004f202b0c6/javalangclassnotfoundexception-commicrosoftsqlserverjdbcsqlserverdriver?forum=sqldataaccess" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/sqlserver/en-US/b425c201-9882-4a48-b049-4004f202b0c6/javalangclassnotfoundexception-commicrosoftsqlserverjdbcsqlserverdriver?forum=sqldataaccess</a></li>
  <li><a href="https://stackoverflow.com/questions/18420675/getting-classnotfoundexception-on-code-class-fornamecom-microsoft-sqlserver">Getting ClassNotFoundException on code: &quot;Class.forName(&quot;com.microsoft.sqlserver.jdbc.SqlServerDriver&quot;);&quot;</a></li>
  </ol>
  
  <p>and many more.</p>
  
  <p>Compiler level 1.7 and a JRE of 1.7 - According to <a href="https://msdn.microsoft.com/en-us/library/ms378526(v=sql.110).aspx" rel="nofollow noreferrer">documentation</a>, I believe I am using the correct driver.  This also states that the CLASSPATH must be set:</p>
  
  <pre><code>echo $CLASSPATH
  /var/common/sqljdbc41.jar
  </code></pre>
  
  <p>Which it is.  Furthermore:</p>
  
  <pre><code>java -version
  java version "1.7.0_75"
  Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
  Java HotSpot(TM)
  64-Bit Server VM (build 24.75-b04, mixed mode)
  </code></pre>
  
  <p>So, why am I still encountering this???</p>
  
  <blockquote>
    <p>Update</p>
  </blockquote>
  
  <p>I downloaded the <code>sqljdbc41.jar</code> from Microsoft again - just to be sure that somehow the first jar was not corrupt.</p>
  
  <p>Following Mick Mnemonic's link, I removed the jar from the Java Build path and put the newly downloaded jar into the <code>WEB-INF/lib</code> folder of the web application.  I then restarted Eclipse and the Tomcat server and cleaned the Tomcat server, and the project.  </p>
  
  <p>Still getting the <code>ClassNotFoundException</code>.</p>
  
  <p>Also, the Eclipse IDE can see the driver:
  <a href="https://i.stack.imgur.com/s9dla.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s9dla.png" alt="enter image description here"></a></p>