Quick Start¶
Get up and running with General SQL Parser in just a few minutes! This guide walks you through installation, basic setup, and your first SQL parsing example — for both the Java and the .NET / C# edition.
Pick your language once
Every example below is a Java / C# tab pair. Select one and every tab on the page switches with it, and the choice follows you to the other pages on this site.
The two editions are API-compatible by design: the same class names
(TGSqlParser, TSelectSqlStatement, TTable), the same vendor enum, the same
AST. Java getters generally become C# properties — the full mapping table is on
the .NET / C# overview.
Prerequisites¶
- Java 8 or higher (Java 11+ recommended)
- Maven or Gradle for dependency management
- IDE (IntelliJ IDEA, Eclipse, or VS Code recommended)
- A .NET SDK. Any currently supported version works. On Ubuntu 24.04:
sudo apt-get install -y dotnet-sdk-10.0; on Windows and macOS use the installer from Microsoft. Confirm withdotnet --info. - Nothing else. No IDE is required — the commands below are the whole toolchain. If you prefer one, Visual Studio, Rider, and VS Code with the C# Dev Kit all work.
The package multi-targets net10.0 and netstandard2.0, so it also runs on
.NET Framework 4.6.2+ — see Framework compatibility.
Installation¶
Both editions install from a public package repository. There is nothing to download, install, or configure locally, and no license file to place.
Add the dependency¶
General SQL Parser is published to Gudu Software's public Maven repository at https://www.sqlparser.com/maven/. Add the repository and a single dependency to your build.
A complete, minimal pom.xml — copy it into an empty directory and it
builds on Java 8 through the latest LTS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
Create your class at src/main/java/QuickStartExample.java (see
Your First SQL Parser below), then compile and
run in one step:
1 | |
That's it — Maven downloads gsqlparser-4.1.9.jar from
https://www.sqlparser.com/maven/com/gudusoft/gsqlparser/4.1.9/ into your
local ~/.m2/ cache on first build.
Data lineage on Java 11+
The DataFlowAnalyzer (data-lineage) APIs generate XML through JAXB, which
was removed from the JDK in Java 11. As of 4.1.6 the published POM
declares the JAXB runtime, so lineage works on Java 11+ with only the GSP
dependency — no extra setup. On Java 8 the JDK-bundled JAXB is used.
A complete build.gradle.kts (Kotlin DSL). The application plugin
supplies the implementation configuration and a run task:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
Create your class at src/main/java/QuickStartExample.java (see
Your First SQL Parser below), then build and run
with the installed Gradle (listed in the prerequisites):
1 | |
Using the Gradle wrapper
An empty project has no gradlew wrapper script yet. Generate one first
with gradle wrapper, after which you can use ./gradlew clean run
(gradlew.bat clean run on Windows) for a version-pinned, reproducible
build.
The library is published to NuGet as
gudusoft.gsqlparser.
Three commands take you from an empty directory to a working parser:
1 2 3 | |
Note the deliberate absence of a version number: dotnet add package
resolves the newest published release and writes it into your project
file, so this command stays correct as new versions ship.
Then paste the program from
Your First SQL Parser into Program.cs and run
it with dotnet run.
A complete, self-contained project file. Save it in an empty directory
next to a Program.cs and run dotnet run:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
In the Visual Studio Package Manager console:
1 | |
License setup: there is none. No license key to embed, no SetLicense
call, no activation step — add the package and start parsing.
The public package is the trial build¶
The Maven artifact is the trial edition
The artifact at com.gudusoft:gsqlparser is the trial edition of
General SQL Parser. It carries every dialect and covers every example on
this page, with two limits that apply to the Java trial exactly as they do
to the .NET one:
- SQL over the 10,000 size limit is refused before parsing.
parse()returns-1andgetErrormessage()reads, verbatim:
1 | |
- The build stops working 90 days after first use.
The boundary is exact: 10,000 passes, 10,001 is refused. What gets
measured depends on how you hand over the SQL — a String (sqltext) is
measured in characters, ignoring leading whitespace, while a file or
stream is measured in raw bytes. For ASCII SQL the two agree; for
non-ASCII text a file can be refused at fewer than 10,000 characters.
A -1 return is never a complaint about your SQL — it means the input was
too long, or the trial expired. Handle it separately from a syntax error:
1 2 3 4 | |
Evaluating long stored procedures or large scripts will hit this quickly, so request an unrestricted evaluation build up front rather than mid-test: send us a SQL sample or email info@sqlparser.com.
Trial versions differ from commercial ones
Commercial builds may carry newer fixes and use a more specific four-part
version. See the licensing FAQ before production use. The public
Maven version is a three-part number (for example 4.1.9) and does not
necessarily match the four-part product version shown in the
release notes.
The three distinct return values
parse() returns 0 on success, a positive count on syntax errors, and
-1 when the trial limit refused the input. Treat -1 as "input too long
or trial expired", not as "invalid SQL".
The NuGet package is the trial edition
gudusoft.gsqlparser on nuget.org is the trial build (the package title
says so). It carries every dialect and behaves exactly like the full edition,
with two limits: SQL longer than 10,000 characters is refused before
parsing, and the build stops working 90 days after first use.
parse() returns -1 and Errormessage reads, verbatim:
1 | |
The boundary is exact, and worth knowing precisely because it sits one
character off from what the message says: a sqltext of 10,000 characters
parses fine, and 10,001 is refused. A -1 return is therefore never a
complaint about your SQL — it means the input was too long. Handle it
separately from a syntax error:
1 2 3 | |
For unrestricted parsing use the full edition. See the licensing FAQ for editions and pricing.
The three distinct return values
parse() returns 0 on success, a positive count on syntax errors, and
-1 when the trial size limit refused the input. Treat -1 as "input too
long", not as "invalid SQL".
Running your program¶
The complete pom.xml above already includes the exec-maven-plugin, so once
you've created QuickStartExample.java you can compile and run in one command:
1 | |
To run a different class, change the plugin's <mainClass> (or override it on
the command line with -Dexec.mainClass=YourClass).
1 | |
That is the whole build-and-run step; the SDK restores, compiles, and executes.
Checking which version you have¶
Releases can land days apart, so this page does not name a current version in its prose. Ask the tooling instead.
Latest version
You can always check the latest published version by viewing
maven-metadata.xml.
Maven coordinates are write-once — once a version is published it never
changes, so it's safe to pin any specific release.
1 2 3 | |
dotnet list package --outdated prints a Requested / Resolved / Latest
table, the fastest way to see whether you are behind. Choose your Version
attribute to match how you want updates:
Version value |
Behaviour | Use when |
|---|---|---|
omitted (dotnet add package) |
Pins the newest version at the time you ran the command | Default. Reproducible, and you upgrade deliberately. |
4.* |
Floats to the newest 4.x on every restore |
You want fixes automatically, without risking a major-version jump. |
* |
Floats to the newest version, including future major versions | Rarely. A future 5.0 with breaking changes would land silently. |
exact (4.1.0.7) |
Exact pin | CI, air-gapped feeds, anywhere restore must be deterministic. |
The assembly carries no version metadata
Do not try to read the version at runtime — the shipped DLL reports an
AssemblyVersion of 0.0.0.0 and has no AssemblyInformationalVersion, so
reflection tells you nothing. dotnet list package is the reliable answer.
Framework compatibility¶
The parser JAR is Java 8 bytecode, so it runs on Java 8 through the latest
LTS. Pin maven.compiler.source/target to 1.8 as the pom.xml above does,
so a modern JDK does not fall back to an unsupported default.
The package ships two builds and NuGet picks the right one for your project:
| Your target | Assembly used | Extra dependencies |
|---|---|---|
net10.0 |
lib/net10.0/ |
none |
net8.0, net9.0, netstandard2.0 libraries |
lib/netstandard2.0/ |
System.Text.Json 8.0.5 |
| .NET Framework 4.6.2+ | lib/netstandard2.0/ |
System.Text.Json 8.0.5 |
On .NET Framework the real floor is 4.6.2, not 4.6.1
netstandard2.0 itself is consumable from .NET Framework 4.6.1, but the
netstandard2.0 build depends on System.Text.Json 8.0.5, whose lowest .NET
Framework asset is net462. Targeting net461 leaves that dependency
unresolved. Use net462 or newer.
A netstandard2.0 class library referencing the package builds with zero
warnings — there is no NU1701 fallback noise, because the package genuinely
targets it.
Offline / air-gapped installs¶
If your build environment cannot reach the internet, you must transfer the
complete dependency closure — not just the GSP JAR. Since 4.1.6 declares
JAXB (which lives on Maven Central), installing only the GSP JAR and POM is not
enough: Maven would still try to fetch jakarta.xml.bind-api, jaxb-runtime,
and the build/exec plugins from a remote repository.
The reliable approach is to build a portable local repository on a
connected machine and transfer it whole. Prime it by running the actual build
commands once — this captures the exact plugin + dependency closure the build
uses. (dependency:go-offline is not sufficient here: it misses some
default-lifecycle plugin dependencies and the build still fails offline.)
On a machine with internet access — using the complete pom.xml and
QuickStartExample.java from the sections above:
1 2 3 4 5 | |
Transfer the project directory and the offline-m2/ folder to the
air-gapped host, then run the same offline command there:
1 | |
Verifying artifact integrity
The published JAR checksum can be checked against the download:
1 2 3 | |
Releases published after 2026-07-31 also carry a CycloneDX SBOM next to
the JAR, named gsqlparser-<version>-cyclonedx.json, for security review
and dependency scanners. It lists the complete dependency closure a
consumer resolves — the parser itself plus the JAXB chain, with licenses
and digests — and carries the JAR's own SHA-256, so the document can be
tied to the file you downloaded. Versions up to and including 4.1.9
predate it.
Transfer a folder feed. The GSP package has no dependencies on net10.0,
so for a modern TFM the feed is a single 6.7 MB .nupkg. (Targeting
netstandard2.0 or .NET Framework adds System.Text.Json and its transitive
closure — restore on the connected machine with the same TFM you will build
with, so the feed captures everything.)
On a machine with internet access, pin an exact version first: a floating
4.* cannot resolve against a feed that will never receive updates.
1 2 3 4 5 | |
Transfer the project directory together with offline-feed/, then on the
air-gapped host add a nuget.config beside the .csproj:
1 2 3 4 5 6 7 | |
1 2 | |
The <clear /> matters: without it NuGet keeps nuget.org in the source list
and restore fails on a network timeout rather than reading your folder.
Your First SQL Parser¶
Let's create a simple example that parses a SQL statement:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
Expected output:
1 2 3 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
Output:
1 2 | |
To parse a file instead of a string, set
parser.sqlfilename = @"C:\scripts\schema.sql"; (it is a string property;
setting one input clears the other).
Why the API mixes casing
The .NET edition is a port of the Java edition, and it keeps the Java member names where they were fields. That is deliberate, so Java examples elsewhere on this site translate mechanically — but it means casing is inconsistent by design:
- Java-style lowercase:
sqltext,sqlfilename,parse(),sqlstatements,sqlstatementtype,tables,sourcetokenlist - C# properties:
Errormessage,ErrorCount,SyntaxErrors,WhereClause,ResultColumnList,Statements,DbVendor - Lists use
size()andget(i)methods, notCountand indexers
The full mapping table is on the .NET / C# overview.
Database Vendor Support¶
Pass a different EDbVendor to the constructor — the rest of your code is
unchanged. Always match the vendor to the SQL's actual dialect: SELECT TOP 10
parses under dbvmssql and is a syntax error under dbvoracle.
The two editions do not cover the same vendor list
Java's EDbVendor declares 45 constants; the .NET build declares 23, and
three of those throw. Java is a superset — do not assume a vendor available in
one edition exists in the other. Each tab below lists only what that edition
actually supports.
General SQL Parser for Java supports 40+ database vendors. Some common examples:
1 2 | |
1 2 | |
1 2 | |
1 2 | |
1 2 | |
The .NET build ships 15 dedicated dialect grammars: dbvdb2,
dbvgreenplum, dbvhive, dbvimpala, dbvinformix, dbvmdx, dbvmssql,
dbvmysql, dbvnetezza, dbvoracle, dbvpostgresql, dbvredshift,
dbvsnowflake, dbvsybase, dbvteradata.
1 2 | |
1 2 | |
1 2 | |
1 2 | |
1 2 | |
The enum declares 23 constants, so the other eight need explaining:
Three constants throw, five are T-SQL in disguise
dbvbigquery, dbvhana, and dbvdax throw NotSupportedException from
the TGSqlParser constructor. They exist for resolver / sqlenv vendor maps,
not for parsing, and the exception message says so. Do not offer them in a
dialect dropdown. Note that dbvbigquery does work in the Java edition —
this is one of the places the two diverge.
dbvaccess, dbvansi, dbvgeneric, dbvodbc, and dbvfirebird resolve
to the T-SQL grammar. Tested against seven dialect-specific probes, all five
behave identically to dbvmssql in every case — they accept SELECT TOP 10
and reject MySQL backticks, PostgreSQL :: casts, Snowflake QUALIFY, and
Firebird's own FIRST/SKIP. If you pick dbvansi expecting strict standard
SQL, or dbvfirebird expecting Firebird, you get T-SQL behaviour instead.
dbvaccess is a distinct enum value, not an alias of dbvmssql.
dbvmdx is a real grammar, but MDX is a different language: ordinary SQL such
as SELECT a FROM t fails under it. Use it only for genuine MDX.
Per-dialect syntax coverage tables are in the SQL syntax support reference.
Common Use Cases¶
1. SQL Syntax Validation¶
parse() == 0 confirms the SQL is syntactically valid for the selected
dialect. It does not check that the referenced tables/columns exist, that
types are compatible, or that the statement would execute — catalog-aware
validation requires metadata and the resolver APIs.
1 2 3 4 5 | |
1 2 3 4 5 | |
2. Extract Table Names¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
TGSqlParser and EDbVendor live in the root gudusoft.gsqlparser package,
while AST nodes like TTable live in gudusoft.gsqlparser.nodes and
statements like TSelectSqlStatement in gudusoft.gsqlparser.stmt. Import
all four or the snippet will not compile.
Pick the right accessor — this is a common trip-up:
| Method | Returns | For FROM dbo.employees e |
|---|---|---|
table.getFullName() |
String |
dbo.employees — schema-qualified. Use this for dependency graphs. |
table.getName() |
String |
employees — bare name, no schema. |
table.getAliasName() |
String |
e — the alias, or empty when there is none. |
table.getTableName() |
TObjectName |
An AST node, not a String. It renders as dbo.employees via toString(), so it looks interchangeable with getFullName() inside string concatenation — but it is not. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
Output:
1 2 | |
Pick the right member for the job — this is a common trip-up:
| Member | Type | Value above |
|---|---|---|
table.FullName |
string |
dbo.employees — schema-qualified. Use this for dependency graphs. |
table.Name |
string |
employees — bare name, no schema. |
table.AliasName |
string |
e — the alias, or empty when there is none. |
table.TableName |
TObjectName |
An AST node, not a string. It renders as dbo.employees through ToString(), so it looks interchangeable with FullName inside string interpolation — but it is not. |
Statements nest — procedure bodies, BEGIN...END blocks, IF branches, and
the SELECT inside an INSERT. A CREATE PROCEDURE reports tables=0
itself: the tables belong to the statements inside the body. Recurse
through stmt.Statements to reach them, or a dependency inventory finds
nothing:
1 2 3 4 5 6 7 8 9 | |
For a procedure that archives then deletes:
1 2 3 4 5 6 7 8 | |
GO separators are statements, not whitespace
In a T-SQL script, three SQL statements plus two GO batch separators produce
five entries in sqlstatements, with GO surfacing as sstmssqlgo. That
is useful when round-tripping a script, but it will surprise you if you
assumed the count matched your statements. Skip them when you only want real
work:
1 | |
3. Format SQL¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
Output:
1 2 3 4 5 | |
Error Handling¶
Always handle parsing errors gracefully:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
Output:
1 2 | |
TSyntaxError exposes lineNo, columnNo (both long), tokentext,
hint, errortype, and errorno — enough for an editor plugin or CI gate to
underline the offending token. Note that hint is a short restatement of the
parser state rather than a human-friendly suggestion; lineNo, columnNo and
tokentext are the fields worth surfacing to users.
checkSyntax() is an alias of parse() with the same return contract, if you
prefer the intent-revealing name for validation-only code paths.
Next Steps¶
Now that you have General SQL Parser running, explore these areas:
Continue Learning
- Getting Started with GSP - Comprehensive tutorial
- Basic SQL Parsing - Learn parsing fundamentals
- Working with Different Databases - Multi-vendor support
- Performance Optimization - Speed up your parsing
- Error Handling - Robust error management
- Parse Oracle PL/SQL - Advanced Oracle features
- API Documentation - Complete API reference
- SQL Syntax Support - Supported SQL features
- Configuration Options - Parser configuration
- .NET / C# overview - Java-to-C# API translation table
- AST node reference - Same AST in both editions
- Release notes - What changed
Troubleshooting¶
Common Issues¶
Parse Error: Unexpected token
Solution: Check that you're using the correct database vendor. SQL syntax varies between databases.
1 2 3 4 5 6 7 | |
1 2 3 4 5 6 7 | |
OutOfMemoryError / OutOfMemoryException
Solution: For large SQL files, parse statements individually rather than loading a multi-megabyte file as one string.
Increase the JVM heap size, or split the input. See the performance optimization guide.
Split the input. See the performance optimization guide.
Class or type not found at runtime
ClassNotFoundException — ensure the GSQLParser JAR is on your classpath
and all dependencies are included.
TypeLoadException / FileNotFoundException — check your target
framework. Use net462 or newer on .NET Framework, not net461; see
Framework compatibility. On .NET Core, net5.0
and older netcoreapp* targets are EOL; upgrade.
parse() returned -1
Your input is over the 10,000 size limit, or the trial expired 90 days after
first use. That is the trial limit, not a problem with your SQL. This applies
to the Java trial and the .NET trial alike — both public packages are trial
builds. Read the exact message from getErrormessage() (Java) or
Errormessage (C#) to tell the two causes apart. Split the script, or use the
full edition. See
The public package is the trial build.
C# only: NotSupportedException from the constructor
You passed dbvbigquery, dbvhana, or dbvdax. These have no parser grammar in
the .NET build, though dbvbigquery works in Java. See
Database Vendor Support.
C# only: NU1701 warning, or dbvsnowflake does not exist
You are on a pre-4.x NuGet package. Versions up to 3.3.0.4 were .NET Framework
4.5 builds that restored through AssetTargetFallback and predate several
dialects. Run dotnet add package gudusoft.gsqlparser to move to the current
release.
Getting Help¶
- 📖 Check our FAQ for common questions
- 💬 Visit our Support page for community help
- 📧 Contact technical support for commercial licenses
Ready for more advanced features? Continue with our comprehensive tutorials or explore specific how-to guides.