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

org.hotrod.utils.SQLUtil Maven / Gradle / Ivy

The newest version!
package org.hotrod.utils;

import org.nocrala.tools.lang.collector.listcollector.ListWriter;

public class SQLUtil {

  public static String cleanUpSQL(final String select) {
    ListWriter lw = new ListWriter("\n");
    String[] lines = select.split("\n");

    // Trim lines and remove empty ones

    for (String line : lines) {
      String trimmed = line.trim();
      if (!trimmed.isEmpty()) {
        lw.add(line);
      }
    }

    // Remove trailing semicolons

    String reassembled = lw.toString();
    while (reassembled.endsWith(";")) {
      reassembled = reassembled.substring(0, reassembled.length() - 1);
    }

    return reassembled.trim();
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy