JSqlParser turns SQL text into a Java object tree you can traverse, rewrite, and print back. One grammar covers major databases including PostgreSQL, MySQL, Oracle, SQL Server, DuckDB, and Snowflake.
Overview
JSqlParser accepts SQL strings and returns an abstract syntax tree built from Java classes. Visitor patterns walk the tree, and a fluent API can construct statements programmatically before rendering them as SQL text again.
The grammar spans SELECT and DML statements, DDL, maintenance commands, transactions, cursors, security policies, and vendor-specific syntax across a dozen major engines. Bind parameters, window functions, hints, and nested subqueries are supported.
Current Manticore builds on Maven are considerably faster than older 5.3 releases and faster than several cross-language parsers in project benchmarks. Dialect-specific behavior can be enabled through parser configuration objects.
Typical uses include SQL analysis, rewriting queries in tools, or building database middleware on the JVM without native database extensions.
Key features
- Parse SQL into traversable Java AST
- Fluent API to build SQL from Java
- Visitor pattern tree navigation
- Broad multi-dialect grammar coverage
- Rewrite and depretty-print SQL text
- Prepared statement and bind parameter support
Use cases
- Analyze SQL in Java database tools
- Rewrite queries before execution
- Build SQL-aware linters or formatters