Reputation: 509
I am trying to escape a whole string for insert into a longtext or varchar. Basically I have a string full of all types of special characters and special words (ex. LIKE) and I just want to escape the whole thing so that I can insert it into my H2 database.
I've asked a few friends and they said that I should try serializing the data. Is this the proper way to insert random strings into the db? Should I be trying to do this with prepared statements?
Sorry I'm new to H2 and not that great with SQL. Thanks for the help in advance!
Upvotes: 3
Views: 2489
Reputation: 50127
If you are looking for examples on how to use a PreparedStatement
:
Upvotes: 3
Reputation: 109081
Use a PreparedStatement
and pass the string as a parameter.
Upvotes: 3