• Post Reply Bookmark Topic Watch Topic
  • New Topic

OK here's a daft SQL problem for you...  RSS feed

 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK second post of the day. Got my DB working and got my JSPs displaying and removing and inserting data, etc... But!

Noticed a problem in the code. If in and of the text firlds I put a ' or " symbol, it kills the SQL. I know this is because the query string is just that, a string (in Java/JSP); and the quote is obviously cutting off the end of the string. But does anyone know away round this? Aparft from the obvious, don't have ' or " in the string! :-)
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65899
135
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using parameterized PreparedStatements? If not, you should. It will handle all the delimiter nonsense for you.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!