I’m trying to compare two variables that I’m getting from json service with a database that I have in my app. I tried to hard coding it and it worked
Statement st = tmsDB.createStatement(
"SELECT * FROM ObjectTexts WHERE programID ='AAA' AND objName ='BBB'");
But when I tried to do this `
Statement st = tmsDB.createStatement(
"SELECT * FROM ObjectTexts WHERE programID="+ JsonProgramID +"AND objName ="+JsonobjName);
it didn’t work.
Any ideas?
If you observe the hardcoded query your parameters are inside single quotes, but dynamic one missing single quotes.
In SQL all String/Varchar should be inside single quote.
Note: These raw queries are highly vulnerable for SQL injection.
The BlackBerry API supports the normal create, prepare, bind, execute semantics: