我正在构建一个GWT程序,该程序在服务器端连接到名为TheDatabase的数据库。我通过在Java项目中运行代码来测试我的代码,并且它运行得非常好。然而,当我尝试运行它作为GWT项目的一部分,我得到这个错误:找不到合适的JDBC驱动程序驱动程序
java.sql.SQLException: No suitable driver found for jdbc:sqlserver://localhost:1433;databaseName=TheDatabase;integratedSecurity=true;
这是我的功能连接到一个数据库:
public void getConnection(String server, String database) throws SQLException{
this.connection = DriverManager.getConnection("jdbc:sqlserver://" + server + ";" +
"databaseName=" + database +
";integratedSecurity=true;");
}
这就是我所谓的代码当错误发生:
private ResultSet executeQuery(String sqlCommand) throws SQLException{
Statement stat = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
return stat.executeQuery(sqlCommand);
}
你使用的驱动程序是什么,以及什么数据库,即MongoDB,MySQL? – smoggers
我在sqljdbc4.jar中使用SQL Server。我提供了.jar,所以我不知道它来自哪里。 – jpyams