Reputation: 4374
I am building a GWT program that on the server side connects to a database named TheDatabase. I tested my code by running it in a Java project, and it worked beautifully. However, when I try running it as part of the GWT project, I get this error:
java.sql.SQLException: No suitable driver found for jdbc:sqlserver://localhost:1433;databaseName=TheDatabase;integratedSecurity=true;
This is my function to connect to a database:
public void getConnection(String server, String database) throws SQLException{
this.connection = DriverManager.getConnection("jdbc:sqlserver://" + server + ";" +
"databaseName=" + database +
";integratedSecurity=true;");
}
And this is the code I call where the error happens:
private ResultSet executeQuery(String sqlCommand) throws SQLException{
Statement stat = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
return stat.executeQuery(sqlCommand);
}
Upvotes: 0
Views: 2095
Reputation: 64561
Server-side dependencies should be in the WEB-INF/lib
folder of your war folder. It's not enough to put them in the DevMode classpath.
Upvotes: 1
Reputation: 2493
You have to download the driver's .jar file and make it available in you claspath, so the DriverManager can instantiate it by reflection, based on your connection string.
However, in GWT while you program all in Java, there is a server-side code and a client-side code, that ends up compiled as Javascript. Are you sure you are not trying to connect to the DB from the client part of your code? (Based on your comment that it worked before you turned it into a GWT project).
Also, make sure you haven't checked the "Google App Engine" setting of you project, because GAE does not work with JDBC (check this just in case: JDBC Driver does not work with GWT?)
Upvotes: 0