El Duderino
El Duderino

Reputation: 509

Escaping a full string in H2 insert statement

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

Answers (2)

Mark Rotteveel
Mark Rotteveel

Reputation: 109081

Use a PreparedStatement and pass the string as a parameter.

Upvotes: 3

Related Questions