问题描述
我试着使用SQLite 命令一个SQLite数据库连接到另一个黑莓
I'm trying to attach one SQLite database to another on BlackBerry using SQLite ATTACH DATABASE command.
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();
我发现了一个异常附加数据库/SDCard/Databases/SQLiteExample/MyTestDatabase2.db作为SECOND_TABLE:SQLlogic错误或丢失的数据库
当它试图prepare语句附加数据库命令。
I'm getting an Exception ATTACH DATABASE /SDCard/Databases/SQLiteExample/MyTestDatabase2.db' as SECOND_TABLE: SQLlogic error or missing database
when it tries to prepare statement for "Attach Database" command.
时有可能使用附加数据库
黑莓SQLite的API命令?
Is it possible to use ATTACH DATABASE
command with BlackBerry SQLite API?
感谢。
推荐答案
没有,黑莓实施的SQLite不支持附加数据库。参阅BlackBerry文档使用SQLite数据库工作进行确认。
No, the BlackBerry implementation of SQLite does not support ATTACH DATABASE. See the BlackBerry documentation "Working with SQLite databases" for confirmation.
这篇关于黑莓SQLite的:连接一个SQLite数据库到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!