run java `static void buildCCJSqlParser() throws IOException, JSQLParserException {
final Path path = Paths.get("/Users/xxx/xxx", "xxx-xxx-comm.sql");
final byte[] bytes = Files.readAllBytes(path);
ExecutorService executorService = Executors.newSingleThreadExecutor();
final CCJSqlParser ccjSqlParser = CCJSqlParserUtil.newParser(new ByteArrayInputStream(bytes), StandardCharsets.UTF_8.name());
final Statements statements = CCJSqlParserUtil.parseStatements(ccjSqlParser, executorService);
final int[] updateCounter = {0};
final int[] alterCounter = {0};
final int[] selectCounter = {0};
StatementVisitorAdapter adapter = new StatementVisitorAdapter(){
@Override
public void visit(Update update) {
final String name = update.getTable().getName();
final String schemaName = update.getTable().getSchemaName();
updateCounter[0]++;
System.out.printf("Update: table:%s, schema:%s%n", name, schemaName);
}
@Override
public void visit(Alter alter) {
final String name = alter.getTable().getName();
final String schemaName = alter.getTable().getSchemaName();
alterCounter[0]++;
System.out.printf("Update: table:%s, schema:%s%n", name, schemaName);
}
};
statements.accept(adapter);
System.out.println(updateCounter[0] + ", " + alterCounter[0] + ", " + selectCounter[0]);
Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram
Failing SQL Feature:
Brief description of the failing SQL feature
Example:
Encountered unexpected token: "IF" "IF"can't be parsedrun java `static void buildCCJSqlParser() throws IOException, JSQLParserException {
}`
SQL Example:
Software Information:
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.