I need parser on java that parse SQL and return it as some structure. This structure must have some binding point to what I can bind low level reader.
2 Answers
In case you need to did a little deeper than @Adamski's Zql, take a look at ANTLR, which has grammars for most flavors of SQL.
7 Comments
merin
And where I can get an engine that handles: joins, group by, etc? Zql, Antlr are only parsers.
ZZ Coder
Have you looked at Apache Derby?
Nick Holt
@merin: what do you mean by 'handles'? Do you want to execute the SQL in some way or just get it into some tree structure? It's been a while since I used ANTLR but from memory it will generate an AST that can optionally contain custom nodes.
merin
Ya, you right: I want execute SQL, but low level is written by me. I have Paradox db, but my jdbc driver it's a pure java code and it's reads the file structure. I want to end my paradox jdbc driver by supporting of SQL.
Nick Holt
@merin: so if I remember rightly Paradox doesn't support SQL and so what you want to do is process a SQL statement in order to retrieve data from a Paradox DB, right? This is considerably more complicated that simply parsing the SQL, you need to generate, optimize and execute a query plan. This first step will be the parsing (which ANTLR will help with) but as I'm not familiar with Paradox I can't really tell you much more than that, other than it'll be quite a task. I'd suggest your time would be better spent getting the data into a modern DB that already supports SQL.
|
How about parse sql and then generate XML output with query structure information. then you can use this XML which including SQL parse tree for further investigation.