Q:

Connecting MS SQL database to a Java program

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....."
Why is this happening?
Here is the 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();                
        }
    }
}

I used sqljdbc.jar as my driver and I added it on my classpath.

A:

SQLException: No suitable driver found

This exception means that the JDBC URL which is been used to get the connection isn't supported by any of the JDBC drivers loaded as far. So, this exception can have at least three possible causes:

The right driver wasn't loaded at all.
Loading the driver failed with an exception which was suppressed which in turn caused that the code continues to run and tries to get the connection instead of aborting.
The JDBC URL is plain wrong.

Let's look what you've as far:

You're using a Microsoft SQL Server database.
You've loaded the Sun JDBC-ODBC bridge driver.
You're using a JDBC URL which is specific to the SQL Server JDBC driver and it looks correct.

Ah right, you've loaded the wrong JDBC driver!
You need the Microsoft SQL Server JDBC driver, or at least the jTDS JDBC driver, which is actually a 3rd party driver which also supports SQL Server, but is been told to be much better than Microsoft's own JDBC driver. You can find in the documentation which driver class name you need to specify to load the driver. For the Microsoft one, it's the following:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

