I have a problem to attach a Database and insert all rows from attached databases to the main.
Here is my code.
public void selectOldDb(String dbName) throws Exception {
createNewDB();
Class.forName("org.sqlite.JDBC");
Connection connOldDb = DriverManager.getConnection("jdbc:sqlite:"+ dbName);
String newDbName = getDirToNewDb();
newDbName = newDbName + "auftraege.db";
Connection connNewDb = DriverManager.getConnection("jdbc:sqlite:"+ newDbName);
connNewDb.prepareStatement("ATTACH DATABASE \"" + connOldDb + "\" AS fromDB").execute();
connNewDb.prepareStatement("INSERT INTO main.auftraege SELECT * FROM fromDB.SendeDS").execute();
connNewDb.close();
connOldDb.close();
}
I become this error when i try to insert.
[SQLITE_ERROR] SQL error or missing database (no such table: fromDB.SendeDS)
What am I doing wrong?
SendeDSis in fact the name of the table you are trying to query. Since I am a native English speaker, I see the possibility that you might have meant eitherSendDSorSenderDSinstead. Such typos are very easy to overlook when you know what it should be. I'm just suggesting that you double check this.