No suitable driver found…

Yes, it’s that newbie to Vaadin, again. This time, I’m trying to see if I can do one of the most basic of tasks: connect to a database.

We use MS SQL Server here (version 2012, I believe) and we’ve been able to connec to it fine in two other Java programs that I’ve written. When attempting to do the same thing using a newly-created Vaadin project, however, I am told that “No suitable driver found for jdbc:sqlserver://192.168.0.248;databaseName=job_orders_2014”. I have checked and made sure that all three .jars from Microsoft are in the build path: sqljdbc.jar, sqljdbc4.jar, and sqljdbc41.jar.

Here’s the ConnectionManager class that I’ve written that only tests whether or not it can get a connection:

[code]
package info.chrismcgee.sky.vaadinsqltest.dbutil;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Logger;

public class ConnectionManager {

Logger logger = Logger.getLogger(ConnectionManager.class.getName());

private static final String USERNAME = “web”;
private static final String PASSWORD = “web”;
private static final String CONN_STRING = “jdbc:sqlserver://192.168.0.248;databaseName=job_orders_2014”;

public ConnectionManager() throws SQLException, ClassNotFoundException {

// Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);
Connection conn = null;

    try {
        conn = DriverManager.getConnection(CONN_STRING, USERNAME, PASSWORD);
        System.out.println("Connected!");
    } catch (SQLException e) {
        System.err.println(e);
    } finally {
        if (conn != null) {
            conn.close();
        }
    }
}

}
[/code]No The result is the SQLException message I mentioned earlier. I’ve tried it both with and without that “Class.forName…” line, which is apparently only necessary for Java versions below 7 (and we’re using version 8). When that line is enabled, I get a ClassNotFoundException instead.

What gives?

I neglected to post an answer to this months ago when I was pointed to the correct solution. I shall do so now.

When I didn’t receive a response here for quite some time, I asked this same question
on StackOverflow
and got a response pointing me to
the correct answer
.

In short, just adding the JDBC driver’s .jar file to the Build Path isn’t enough. Inside eclipse, I had to also add an entry to the Deployment Assembly tab of the project’s Properties. Specifically, linking up the JDBC .jar file to WEB-INF/lib.