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?