title: Connecting MS SQL database to a Java program
body: <p>I have a JAVA Class that's trying to connect to a MS SQL database.  Now, when I am trying to connect to the database I got an error "No suitable driver found for....."</p>
  
  <p>Why is this happening?</p>
  
  <p>Here is the code.</p>
  
  <pre><code>DB db = bew DB();
  db.dbConnect();
  
  ...
  
  class DB
  {
      public void dbConnect() {
          try
          {
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              String connectionUrl = "jdbc:sqlserver://web.address.com;" +
                 "databaseName=testdb;user=user.name;password=*****;";
  
              Connection con = DriverManager.getConnection(connectionUrl);
          }
          catch (Exception e)
          {
              e.printStackTrace();                
          }
      }
  }
  </code></pre>
  
  <p>I used sqljdbc.jar as my driver and I added it on my classpath.</p>