[英]how to replace a string value in java
i replace a particular string in a statement like the following 我在如下语句中替换特定的字符串
SQL = SQL.replaceAll("CUSTOMER_NUMBER", customer);
this conversion goes as integer but i want to replace this as a string like the following 此转换为整数,但我想将其替换为字符串,如下所示
AND CIMtrek_accountlist_customer_number = '0002538'
but at present it replaces like the following 但目前它替换如下
AND CIMtrek_accountlist_customer_number = 0002538
how to do this in java. 如何在Java中做到这一点。
Just get it to output the ' as well as the customer variable 只需输出它以及客户变量
SQL = SQL.replaceAll("CUSTOMER_NUMBER", "'" + customer + "'");
However as @jlordo mentioned in a comment, you should look at using prepared statements which will allow you to inject values into a prepared sql statement. 但是,正如@jlordo在评论中提到的那样,您应该查看使用准备好的语句,该语句将允许您将值注入到准备好的sql语句中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.