I am facing a strange problem while creating a file in java using MYSQL.
My code:
String lChildSql = this.lSQLBucket.select("get.child.by.name")
.replace("LEFT").with(lLeft)
.replace("RIGHT").with(lRight)
.replace("LEVEL").with(lLevel + 1)
.replace("NAME").with(pName).get()
ResultSet lChildRs = lDB.Qry(lChildSql);
Sample:If i create a file with pName raj’sek’har and its being created as raj”sek”har automatically.
please help me in solving this issue.
Regards,
Raj
what user unknown is saying is that this is normal behaviour. it’s how sql deals with a single quote (apostrophe) inside a word.
sql uses single quotes for strings –
'this is a string'– but if your string includes a single quote then it will cause problems –'this isn't going to work'– because the string “ends early”.so what sql does is replace that with a two single apostrophes, which is an “escape sequence” to indicate that actually, a single single apostrophe [sic] is required:
'this''ll work fine'.note that this is only for display. it’s not “really” replacing anything, and when you retrieve the data, everything will be fine.
someone else saying the same thing