code: public static String stripSqlCommentsAndWhitespacesFromTheEnd(String sqlString) {
          if (isEmpty(sqlString)) {
              return sqlString;
          }
          StringBuilder str = new StringBuilder(sqlString);
          boolean strModified = true;
          while (strModified) {
              strModified = false;
              // first check for last block comment
              // since line comments could be inside block comments, we want to
              // remove them first.
              String lastBlockComment = getLastBlockComment(str.toString());
              if (isNotEmpty(lastBlockComment)) {
                  str.setLength(str.length() - lastBlockComment.length());
                  // we just modified the end of the string,
                  // do another loop to check for next block or line comments
                  strModified = true;
              }
              // now check for the line comments
              String lastLineComment = getLastLineComment(str.toString());
              if (isNotEmpty(lastLineComment)) {
                  str.setLength(str.length() - lastLineComment.length());
                  // we just modified the end of the string,
                  // do another loop to check for next block or line comments
                  strModified = true;
              }
          }
          return trimRight(str.toString());
      }
docs: Strips the comments and whitespaces from the end of given sql string.
  @param sqlString
  @return