M
m_asu
Guest
Hi All,
I have a discussion forum application through which users submit messages. Users write in the text box, which is then processed by Java into a String query and then executeQuery puts it into MS ACcess database.
My question:
Some characters like ' (single quotes) can screw up the SQL query syntaxt and then the user can get an error and the message may never be posted. I have taken care of the single quote as follows: (assume String variable 'data' represents the message to be posted).
data = data.replaceAll("'", "''");
What this basically does replaces all the single quotes by 2 single quotes each. Thus the query syntax will by maintained. Are there any other characters which can screw up the SQL syntax and which I may have to replace before processing the query?
Thanks in advance.
m_asu
I have a discussion forum application through which users submit messages. Users write in the text box, which is then processed by Java into a String query and then executeQuery puts it into MS ACcess database.
My question:
Some characters like ' (single quotes) can screw up the SQL query syntaxt and then the user can get an error and the message may never be posted. I have taken care of the single quote as follows: (assume String variable 'data' represents the message to be posted).
data = data.replaceAll("'", "''");
What this basically does replaces all the single quotes by 2 single quotes each. Thus the query syntax will by maintained. Are there any other characters which can screw up the SQL syntax and which I may have to replace before processing the query?
Thanks in advance.
m_asu