[英]Escaping a full string in H2 insert statement
I am trying to escape a whole string for insert into a longtext or varchar. 我试图逃避整个字符串插入longtext或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. 基本上我有一个字符串充满了所有类型的特殊字符和特殊字(例如LIKE),我只是想逃避整个事情,以便我可以将它插入我的H2数据库。
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. 对不起,我是H2的新手,而不是那么棒的SQL。 Thanks for the help in advance! 我在这里先向您的帮助表示感谢!
使用PreparedStatement
并将字符串作为参数传递。
If you are looking for examples on how to use a PreparedStatement
: 如果您正在寻找有关如何使用PreparedStatement
示例:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.