Bemace is correct that there seem to be quotes in the title that is screwing up the escaping of strings generated by the query.
Bemace is correct that there seem to be quotes in the title that is screwing up the escaping of strings generated by the query. In ORMLite, you should use the SelectArg feature which will generate a query with SQL? Arguments and then pass the string to the prepared statement directly.
For documentation on the SelectArg, see: ormlite.com/docs/select-arg With SelectArg, you'd do something like: QueryBuilder queryBuilder = StoryDao.queryBuilder(); SelectArg titleArg = new SelectArg(); queryBuilder.where(). Eq(Story. TITLE_FIELD_NAME, titleArg); PreparedQuery preparedQuery = queryBuilder.prepare(); titleArg.
SetValue(title); List accountList = StoryDao. Query(preparedQuery).
I'm not familiar with ORMLite but title = 'Deepcut case leads 'not followed'' doesn't look right. Should probably be "Deepcut case leads 'not followed'" or 'Deepcut case leads \'not followed\'' or some such.
1 Using double quotes or backslash will not work on H2 as it follows the SQL standard. Which means that string literals need to be enclosed in single quotes and to embed another quote you need to use two single quotes: 'Deepcut case leads ''not followed' – a_horse_with_no_name Mar 12 '11 at 8:22 Yes, 'Deepcut case leads ''not followed' is correct according to the SQL standard. All SQL databases support this.
– Thomas Mueller Mar 12 '11 at 9:50 More details: 'Deepcut case leads ''not followed''' is correct according to the SQL standard. All SQL databases support this. "Deepcut case leads 'not followed'" is a quoted identifier, again according to the SQL standard (but I guess there is no such column name).'Deepcut case leads \'not followed\'' is illegal according to the SQL standard, but supported by MySQL and PostgreSQL if SQL compatibility is disabled.
– Thomas Mueller Mar 12 '11 at 9:57 Is there a way to make java auto escape my strings? Or should I write it myself? – Alex Mar 12 '11 at 11:50 @Alex: use a PreparedStatement and you don't have to worry about things like that – a_horse_with_no_name Mar 12 '11 at 12:26.
The correct syntax for the statement would be: SELECT * FROM Stories WHERE title = 'Deepcut case leads ''not followed'' '; Note the duplicated single quotes inside the string literal. You will need to tell your ORM layer to follow the ANSI SQL rules for literals.
The exception says that there is some syntactical problem with your generated SELECT statement. Can you print out the generated query? Doing that might help you pin down the exact issue here.
EDIT: Looking closely at your trace shows that string escaping is not handled properly here. Is this your own QueryBuilder? Also, as per this link, are you using SelectArg or directly setting the title?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.