我收到以下錯誤:的Java:缺少數據庫錯誤
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (no such table: apartments)
在現實中,該表確實存在。下面是我的代碼:
try {
// load the sqlite-JDBC driver using the current class loader
Class.forName("org.sqlite.JDBC");
Connection connection = null;
// create a database connection
connection = DriverManager.getConnection("jdbc:sqlite:/Path/To/apartments.db");
System.out.println(connection.getMetaData());
Statement statement = connection.createStatement();
statement.setQueryTimeout(30);
ResultSet rs = statement.executeQuery("select * from apartments");
while(rs.next()) {
// read the result set
System.out.println("TEXT = " + rs.getString("display_text"));
System.out.println("X1 = " + rs.getInt("x1"));
}
} catch (Exception ex) {
Logger.getLogger(MouseEventDemo.class.getName()).log(Level.SEVERE, null, ex);
}
它說,* SQL錯誤或丟失的數據庫*,我想這不是問題表如何 – Volatil3 2013-02-21 09:32:57
檢查它不會是一個路徑問題? – Volatil3 2013-02-21 09:34:57
我的事情是你的數據庫名稱與表名混淆。你的數據庫名稱是公寓和餐桌的名字也是一樣的? – 2013-02-21 09:35:30