我在Ubuntu 16.04下开发。 我做了一个简单的QPainter调用
SEVERE: Servlet.service() for servlet [Jersey Web Application] in context
with path [/restapi] threw exception [java.lang.IllegalStateException:
Cannot connect the database!] with root cause
java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost:3306/restapi?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
但是valgrind给了我以下错误:
public class AuthService {
private String url = "jdbc:mysql://localhost:3306/restapi?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
public List<User> getAllUsers() {
List<User> users = new ArrayList<User>();
try (Connection conn = DriverManager.getConnection(url, "blabla", "blabla")) {
Statement stmt = conn.createStatement();
String sql;
sql = "SELECT * FROM users";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
int id = rs.getInt("id");
String login = rs.getString("login");
String first = rs.getString("firstname");
String last = rs.getString("lastname");
users.add(new User(id, login, first, last));
}
} catch (SQLException e) {
throw new IllegalStateException("Cannot connect the database!", e);
}
return users;
}
这是什么原因?在QPainter电话中我做错了什么吗? 或者这是一个与我自己的代码无关的Qt / Linux问题?