title: can't load jdbc database driver for MS Microsoft SQL
body: <p>I tried to set a connection between a Servlet and MS SQL SERVER 2012 following the instructions reported on <a href="https://i.stack.imgur.com/rTfRr.png" rel="nofollow noreferrer">this page</a></p>
  
  <p>This is my code:</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      PrintWriter out = response.getWriter();
      try {
          Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
      } catch (ClassNotFoundException e) {
          out.println("Can't load database driver");
          e.printStackTrace();
          return;
      }
  </code></pre>
  
  <p>However, when I run the servlet I get the following error message:</p>
  
  <pre><code>java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
  at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
  at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Unknown Source)
  at demo.Connect.doGet(Connect.java:42)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
  at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>My first suspect was that I messed up with the classpath of the JDBC driver, but     I triple-checked and it looks ok, in fact I can see the sqljdbc.jar inside the Libraries (see image):</p>
  
  <p><img src="https://i.stack.imgur.com/rTfRr.png" alt="project tree"></p>
  
  <p>I also tried the version sqljdbc4.jar,but the results is the same.</p>
  
  <p>Is anybody able to figure out where the problem is and how to solve it?</p>