BlackBerry SQLite:将一个SQLite数据库附加到另一个SQLite数据库

时间:2011-02-01 17:12:45

标签: java sqlite blackberry

我正在尝试使用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();

我收到例外ATTACH DATABASE /SDCard/Databases/SQLiteExample/MyTestDatabase2.db' as SECOND_TABLE: SQLlogic error or missing database 当它试图为“附加数据库”命令准备语句时。

是否可以在BlackBerry SQLite API中使用ATTACH DATABASE命令?

感谢。

2 个答案:

答案 0 :(得分:2)

不,SQLite的BlackBerry实现不支持ATTACH DATABASE。请参阅BlackBerry文档“Working with SQLite databases”以进行确认。

答案 1 :(得分:0)

RIM已在其BlackBerry OS 7.0 API中添加了Attach/Detach Database个命令:
BlackBerry 7.0 API Docs