我正在尝试使用SQLite
ATTACH DATABASE命令将一个SQLite数据库附加到BlackBerry上.
Database d1, d2;
Statement st;
URI dbURI1 = URI.create("file:///SDCard/Databases/SQLiteExample/MyTestDatabase1.db")
if (DatabaseFactory.exists(dbURI1)) {
d1 = DatabaseFactory.open(dbURI1);
} else {
d1 = DatabaseFactory.create(dbURI1);
st = d1.createStatement("CREATE TABLE 'People' ( 'Name' TEXT, 'Age' INTEGER )");
st.prepare();
st.execute();
st.close();
}
URI dbURI2 = URI.create("file:///SDCard/Databases/SQLiteExample/MyTestDatabase2.db");
if (DatabaseFactory.exists(dbURI2)) {
d2 = DatabaseFactory.open(dbURI2);
} else {
d2 = DatabaseFactory.create(dbURI2);
st = d2.createStatement("CREATE TABLE 'People2' ('Name2' TEXT, 'Age2' INTEGER )");
st.prepare();
st.execute();
st.close();
d2.close();
}
st = d1.createStatement("ATTACH DATABASE '/SDCard/Databases/SQLiteExample/MyTestDatabase2.db' as SECOND_TABLE");
st.prepare(); //THROWS AN EXCEPTION "SQL logic error or missing database"
st.execute();
st.close();
我得到一个Exception ATTACH DATABASE /SDCard/Databases/SQLiteExample/MyTestDatabase2.db’作为SECOND_TABLE:SQLlogic错误或缺少数据库
当它试图为“附加数据库”命令准备语句时.
是否可以在BlackBerry SQLite API中使用ATTACH DATABASE命令?
谢谢.
最佳答案 不,SQLite的BlackBerry实现不支持ATTACH DATABASE.请参阅BlackBerry文档“
Working with SQLite databases”以进行确认.