我来自MySQL,我试着学习一些SQLite。我手动创建了一个数据库,并将其放在program files(x86)文件夹中。
连接没有错误,但创建表时会出现以下错误:
org.sqlite.SQLiteException: [SQLITE_CANTOPEN] Unable to open the database file (unable to open database file)
at org.sqlite.core.DB.newSQLException(DB.java:909)
at org.sqlite.core.DB.newSQLException(DB.java:921)
at org.sqlite.core.DB.execute(DB.java:825)
at org.sqlite.core.CoreStatement.exec(CoreStatement.java:75)
at org.sqlite.jdbc3.JDBC3Statement.execute(JDBC3Statement.java:61)
at SQLite.createDatabase(SQLite.java:15)
at Main.main(Main.java:6)
这是我的代码:
Connection cn;
try {
cn = DriverManager.getConnection("jdbc:sqlite:C:\\Program Files (x86)\\CodFiscExtractor\\database.db");
Statement stmt = cn.createStatement();
stmt.execute("CREATE TABLE IF NOT EXISTS warehouses (\n"
+ " id integer PRIMARY KEY,\n"
+ " name text NOT NULL,\n"
+ " capacity real\n"
+ ");");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我该怎么办?