title: JDBC connection from Eclipse to MSSQL server using sqljdbc4.jar
body: <p>I am trying to make a jdbc connection to MS SQL server 2014 using sqljdbc4 from an Eclipse Web project, 
  without any luck whatsoever.</p>
  
  <p>Here is what I have tried so far:</p>
  
  <ol>
  <li>Create a test class outside of the Web project, add jar to build path and try to make a connection - success</li>
  <li>Place jar under project's WEB-INF/lib, add jar to build path with and without adding a Web App Library for the project and try to make a connection - failure</li>
  <li>Place jar under the central Tomcat lib and try to make a connection - failure</li>
  </ol>
  
  <p>Most of the forums have users who have succeeded by doing number (2) in the list above. I am just starting out with JDBC and it took a while to even get to this stage.
  But unfortunately, couldn't get any further. I am stuck at this point for close to 7 hours now and the frustrating thing is it works every time from a regular java project.
  Why is that so, when any kind of project in an IDE requires the jar to be in its classpath?</p>
  
  <p>Not sure how much help this will be of, but here is the code that I had come up with that tries to establish the connection. 
  And it always leads to an SQLException : No suitable driver found for jdbc:sqlserver on the first line after 'try'.</p>
  
  <pre><code>public class SQLConnector {
      private static final String DB_SERVER = "jdbc:sqlserver://SAI;"
                  + "DatabaseName=LibraryManagementSystem";
      private static final String DB_USER="sa";
      private static final String DB_PASS="abc732XYZ";
  
      public static Connection getDatabaseConnection() {
          Connection connection = null;
          try {
              connection = DriverManager.getConnection(DB_SERVER, DB_USER, DB_PASS);
              if(connection != null) {
                  System.out.println("Connection successful");
              }
          }
          catch(SQLException e) {
              e.printStackTrace();
          }
          return connection;
      }
  }
  </code></pre>
  
  <p>Kindly review and help.</p>
  
  <p><a href="http://i.stack.imgur.com/gL79H.png" rel="nofollow">Here is my project tree for the Web application</a></p>