SQLite on BlackBerry giving SQL logic error or missing database error
Hey all, I have the following problem. I recently added an extra column to my database in SQLite and now it's giving me a SQL logic error or missing database error
I made the change to the database and deleted the virtual SD card on the BB simulator to delete the old database and allow the new one to be created on the simulator, the code of the function giving the problem is the following:
public Vector obtenerVoiceNotes()
{
Vector voiceNotes = new Vector();
long id, idRemoto, duracion;
byte[] audioArray;
String nombre, comentario;
try
{
// Se prepara la sentencia SQL
Statement statement = _BD.createStatement("SELECT * FROM VoiceNote WHERE idUsuario = ?");
statement.prepare();
statement.bind(1, MainApp._user.getIdUser());
// Se define un cursor para navegar por el resultado
Cursor cursor = statement.getCursor();
// Se itera sobre el cursor y se agrega al arreglo de notas
while(cursor.next())
{
Row row = cursor.getRow();
id = row.getInteger(0);
开发者_开发问答 audioArray = row.getBlobBytes(1);
nombre = row.getString(2);
comentario = row.getString(3);
idRemoto = row.getInteger(4);
duracion = row.getInteger(5);
long userId = MainApp._user.getIdUser();
VoiceNote voiceNote = new VoiceNote(nombre, comentario, audioArray, userId);
voiceNote.set_id(id);
voiceNote.set_idRemoto(idRemoto);
voiceNote.set_duration(duracion);
voiceNotes.addElement(voiceNote);
}
}
catch (DatabaseException e)
{
System.out.println();
MainApp.messageDialog(e.toString());
} catch (DataTypeException e) {
// TODO Auto-generated catch block
MainApp.messageDialog(e.toString());
}
// Se retorna el arreglo de notas obtenido
return voiceNotes;
}
The exception happens on statement.prepare()
this is the create statement for my table:
CREATE TABLE "VoiceNote" (
"ID" INTEGER PRIMARY KEY NOT NULL ,
"Track" BLOB,
"Nombre" VARCHAR(30) NOT NULL UNIQUE,
"Comentario" VARCHAR(80),
"idRemoto" INTEGER NOT NULL DEFAULT -1,
"Duracion" INTEGER NOT NULL DEFAULT 0,
"idUsuario" INTEGER NOT NULL DEFAULT -1)
The new column is idUsuario
if i revert the change there no longer is any problem, any ideas?
Sounds like the database had been changed but not committed - meaning that the next query to the database would return a 'corrupted' state.
Be sure to commit any changes - and make sure extreme changes like this if done on the fly are carried out on a locked database (don't want any other pesky threads trying to access it!)
I managed to solved this. I deleted the application from the simulator along with the SD card. I dumped and recreated the database to ensure I have the correct logic on the phone and it worked fine.
精彩评论