All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xiongyingqi.common.utils.sql.SqlUtils Maven / Gradle / Ivy

The newest version!
package com.xiongyingqi.common.utils.sql;

import com.xiongyingqi.common.utils.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

/**
 * @author xiongyingqi
 * @since 20171012//
 */
public abstract class SqlUtils {
  private static final Logger logger = LoggerFactory.getLogger(SqlUtils.class);

  /**
   * Convert args array to mysql in statements.

* For example:
* args={1,2,3,4}
* Results:
* ('1','2','3','4') * * @param args in args * @return Statements of in. */ public static String buildArgsToInStatements(String[] args) { Assert.notEmpty(args); String delimiter = ""; StringBuilder builder = new StringBuilder("("); for (String arg : args) { builder .append(delimiter) .append("'") .append(arg) .append("'") ; delimiter = ","; } builder.append(")"); String statementIn = builder.toString(); if (logger.isDebugEnabled()) { logger.debug("Build args: {} to sql statements: {}", Arrays.toString(args), statementIn); } return statementIn; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy