GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Encountered unexpected token: "\n\n\n" <ST_SEMICOLON> · Issue #1988 · JSQLParser/JSqlParser

Encountered unexpected token: "\n\n\n" <ST_SEMICOLON> #1988

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Encountered unexpected token: "\n\n\n" <ST_SEMICOLON>#1988
Copy link

Description

@pansong291
pansong291
opened on Apr 9, 2024
Issue body actions

Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram

Failing SQL Feature:

  • Brief description of the failing SQL feature
    net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "\n\n\n" <ST_SEMICOLON>
      at line 1, column 39.
    

SQL Example:

  • Simplified Query Example, focusing on the failing feature
    UPDATE shop_info  SET title=?,
    
    
    
    
    props=?  WHERE id=?
  • This SQL statement is dynamically concatenated in the program using a third-party library, so it is not possible to remove the extra blank lines within it. Even with the extra blank lines, it can be executed normally in MySQL, which means it does not have syntax errors.

Software Information:

  • JSqlParser version 4.6
  • Database MySQL

Tips:

Please write in English and avoid Screenshots (as we can't copy and paste content from it).
Try your example online with the latest JSQLParser and share the link in the error report.
Do provide Links or References to the specific Grammar and Syntax you are trying to use.

http://jsqlformatter.manticore-projects.com/jsqlformatter/demo.html?args=-c%20KoBQIgggKgogBAZwBYHsAOB9AlgOwGYpxwDKMUcALlhQDYCmAvAPwA0AUBx2gE7oLNEA6gAkYAJXhYAJsyA

Activity

  1. manticore-projects
    pinned this issue on Apr 9, 2024
  2. manticore-projects commented on Apr 9, 2024

    @manticore-projects
    manticore-projects
    on Apr 9, 2024
    Contributor
    More actions

    Greetings!

    Two empty lines \n\n\n terminate a statement. There is no good reason for a statement to contain more than 1 empty line, but there are many good reasons to split statements at empty lines when you don't want to write semicolons.

    If you still insist on empty lines then just use something like String.replaceAll("\n\n+", "\n").

  3. manticore-projects
    closed this as not plannedon Apr 9, 2024
  4. pansong291 commented on Apr 10, 2024

    @pansong291
    pansong291
    on Apr 10, 2024
    Author
    More actions

    @manticore-projects Hello, I don't think it's that simple. Consider the following SQL statement, it cannot simply replace empty lines:

    update shop_info set title=?,
    
    
    
    content='abc
    
    
    
    def'
    where id=?
  5. manticore-projects commented on Apr 18, 2024

    @manticore-projects
    manticore-projects
    on Apr 18, 2024
    Contributor
    More actions

    With JSQLParser 4.10 Snapshot, you can use the method CCJSqlParserUtil.sanitizeSingleSql( sqlStr) to sanitize your statement. It will remove the redundant empty lines using a regular expression which honors StringLiteral.

        @Test
        void testSingleStatementWithEmptyLines() throws JSQLParserException {
            String sqlStr = "update shop_info set title=?,\n"
                            + "\n"
                            + "\n"
                            + "\n"
                            + "content='abc\n"
                            + "\n"
                            + "\n"
                            + "\n"
                            + "def'\n"
                            + "where id=?";
    
            Statement statement = CCJSqlParserUtil.parse( CCJSqlParserUtil.sanitizeSingleSql( sqlStr) );
            TestUtils.assertStatementCanBeDeparsedAs(statement, "update shop_info set title=?,\n"
                                                                + "content='abc\n"
                                                                + "\n"
                                                                + "\n"
                                                                + "\n"
                                                                + "def'\n"
                                                                + "where id=?", true);
        }
  6. manticore-projects
    changed the title [-][BUG] JSQLParser Version : 4.6 : Encountered unexpected token: "\n\n\n" <ST_SEMICOLON> at line 1, column 39.[/-] [+]Encountered unexpected token: "\n\n\n" <ST_SEMICOLON>[/+] on May 1, 2024
  7. manticore-projects
    marked [BUG] JSQLParser 5.0: RDBMS : SQL was automatically intercepted #2193 as a duplicate of this issue on Mar 19, 2025
  8. manticore-projects
    marked [BUG] JSQLParser Version 5.0 : MYSQL: CCJSqlParserUtil.parse() silently drops WHERE conditions when SQL contains excessive blank lines or mixed whitespace #2346 as a duplicate of this issue on Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.