有人可以帮助我,编程工作正常,但我仍然得到这个错误。当我运行该程序时,它一直在说;
java.sql.SQLException:没有为jdbc找到合适的驱动程序:mysql:// localhost:3306 / geckoboard
public class DBConnection {
public static Connection conn;
public Statement statement;
public ResultSet rs;
public static Connection setDBConnection() throws SQLException {
String databaseServer = PropertiesService.getDatabaseServer();
String databasePort = PropertiesService.getDatabasePort();
String databaseUsername = PropertiesService.getDatabaseUsername();
String databasePassword = PropertiesService.getDatabasePassword();
String databaseDatabase = PropertiesService.getDatabaseDatabase();
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://" + databaseServer
+ ":" + databasePort + "/" + databaseDatabase,
databaseUsername, databasePassword);
} catch (ClassNotFoundException e) {
System.out.println(e);
}
return conn;
}
public ResultSet getResultSet(String sqlQuery, Connection conn)
throws SQLException {
System.out.println(sqlQuery);
String sqlquery = sqlQuery;
// conn = conn;
try {
statement = conn.createStatement();
rs = statement.executeQuery(sqlquery);
} catch (SQLException se) {
System.out.println(se);
} finally {
rs.close();
conn.close();
}
return rs;
}
}
答案 0 :(得分:0)
尝试将驱动程序jar放在服务器lib文件夹中。
$CATALINA_HOME/lib