The problem of splicing condition of mysql in function

String [] orderIds = query.getOrderId (). Split (",");

    StringBuffer buffer = new StringBuffer();
    for (String orderId : orderIds) {
        buffer.append(orderId).append(",");
    }
    buffer.deleteCharAt(buffer.length() - 1);
    String sql = "select order_id,pay_status from order_info where order_id in ("+buffer.toString()+")";
    List<OrderInfoTo> list = jdbcService.queryEntityList(OrderInfoTo.class,sql);
    

throw an exception:
PreparedStatementCallback; bad SQL grammar [select order_id,pay_status from order_info where order_id in (170606100349, 170606100376, 170606100396)]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column "ys170606100349" in" where clause"

this method has been used all the time, and I have never thrown an exception. Suddenly today, when I was doing another requirement, I used this method to query, and suddenly I threw an exception. How to solve it? what is the reason

?
Mar.21,2021

Unknown column 'ys170606100349' in' where clause' he says that the unrecognized ys170606100349 is not ys.
you print sql and see if you can run it

.
Menu