Yet another Java SQL Parser plea

Yet another Java SQL Parser plea

Post by Paul Brinkle » Wed, 15 Jan 2003 06:52:16



Search on

  Java "SQL parser"

on groups.google.com, sort by date.  There doesn't seem to be
terrifically high demand for this, oddly.  Even so, I find myself in
need of one.

The most common reference I've seen is to something called ZQL.
However, half the time, the link to it goes 404.  The other half of
the time, I find something several years old, and apparently quite
incomplete.

I've been lending some consideration for about a week now to beginning
an open-source Java SQL parser project on Sourceforge.  I would go for
pure SQL2 compliance (using the docs I found at
http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt and
http://www.contrib.andrew.cmu.edu/~shadow/sql/sql2bnf_aug92.txt as
guides).  I would try to implement the parser in such a way that it
could subclassed reasonably easily, to allow vendor-specific parsers,
as well as a SQL3-compliant version.  I'm sure this would be a massive
undertaking.  The BNF doc alone is over 60Kb.

I'm ambivalent on whether to use JavaCC - it's the only parser
generator I know of, but I know it only by name. I would also guess
it's very generic; it wouldn't generate instances of a nice
SQL-specific class library (I think; I skimmed the FAQ).  I went to
the JavaCC Grammar Repository, and found two SQL grammars, but they're
both Oracle-specific.

Would there be any community interest in an OS Java SQL parser
project?

Paul Brinkley

 
 
 

Yet another Java SQL Parser plea

Post by Guillermo Labatt » Wed, 15 Jan 2003 07:24:53


When I needed a SQL parser for a project I used this:

http://www.antlr.org/

They also have a SQL grammar.


> Search on

>   Java "SQL parser"

> on groups.google.com, sort by date.  There doesn't seem to be
> terrifically high demand for this, oddly.  Even so, I find myself in
> need of one.

> The most common reference I've seen is to something called ZQL. However,
> half the time, the link to it goes 404.  The other half of the time, I
> find something several years old, and apparently quite incomplete.

> I've been lending some consideration for about a week now to beginning
> an open-source Java SQL parser project on Sourceforge.  I would go for
> pure SQL2 compliance (using the docs I found at
> http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt and
> http://www.contrib.andrew.cmu.edu/~shadow/sql/sql2bnf_aug92.txt as
> guides).  I would try to implement the parser in such a way that it
> could subclassed reasonably easily, to allow vendor-specific parsers, as
> well as a SQL3-compliant version.  I'm sure this would be a massive
> undertaking.  The BNF doc alone is over 60Kb.

> I'm ambivalent on whether to use JavaCC - it's the only parser generator
> I know of, but I know it only by name. I would also guess it's very
> generic; it wouldn't generate instances of a nice SQL-specific class
> library (I think; I skimmed the FAQ).  I went to the JavaCC Grammar
> Repository, and found two SQL grammars, but they're both
> Oracle-specific.

> Would there be any community interest in an OS Java SQL parser project?

> Paul Brinkley



 
 
 

Yet another Java SQL Parser plea

Post by Carl Rosenberge » Wed, 15 Jan 2003 07:27:31



> Would there be any community interest in an OS Java SQL parser
> project?

Yes !

In the long run we want an SQL layer on top of our object
query API...
http://sourceforge.net/projects/sodaquery
...and we will certainly need an SQL parser.

I can't promise to contribute any work immediately though.

Before you start writing your own parser, you should definitely
take a look at this project:
http://ldbc.sourceforge.net

I believe it includes a parser but I don't know how well it works.

Kind regards,
Carl
--
Carl Rosenberger
db4o - database for objects - http://www.db4o.com

 
 
 

Yet another Java SQL Parser plea

Post by Paul Brinkle » Wed, 15 Jan 2003 08:06:15


On Mon, 13 Jan 2003 19:24:53 -0300, Guillermo Labatte


>When I needed a SQL parser for a project I used this:

>http://www.antlr.org/

>They also have a SQL grammar.

Thanks for the link.  I went from there to its FAQ - as much as I
loathe JGuru's FAQ interface :-), this FAQ in particular is very
informative.

The problem I have with any generic parser is that it won't
automatically generate any nice Java classes.  For example, I'd want
these hypothetical classes:

Insert
Delete
Select
SelectInto
CreateTable
etc.

All of these would inherit the appropriate superclasses (say,
DDLStatement, SQLStatement, etc.), and implement appropriate methods
(Select might implement getTables, getColumns, getSearchCondition,
etc.).  This is ultimately what I'm looking for.

Naturally, I wouldn't expect a generic parser to do this.  :-)  But I
would probably like to leverage an existing grammar tool, be it ANTLR,
JavaCC, or something else, and build software that outputs the nice
Java objects I'm looking for.

So here's a rephrasal.  What is the interest level in an open-source
Java SQL Parser that outputs classes as above?  And should it be built
using an existing grammar tool (probably, for sanity's sake), and if
so, which one?

Paul Brinkley

 
 
 

Yet another Java SQL Parser plea

Post by Paul Brinkle » Wed, 15 Jan 2003 08:11:34




Quote:

>Before you start writing your own parser, you should definitely
>take a look at this project:
>http://ldbc.sourceforge.net

>I believe it includes a parser but I don't know how well it works.

LDBC looks pretty cool, but nowhere does it generate, say, Select
objects, CreateTable objects, and so forth.  This is what I'm looking
for in particular.  (If no one else is that interested in this, then I
probably won't pursue it very far.  :-) )  It's possible that the
project I'm envisioning might be built on top of LDBC, but I'm not
sure.

Paul Brinkley

 
 
 

Yet another Java SQL Parser plea

Post by Carl Rosenberge » Wed, 15 Jan 2003 08:29:37



> LDBC looks pretty cool, but nowhere does it generate, say, Select
> objects, CreateTable objects, and so forth.  This is what I'm looking
> for in particular.  (If no one else is that interested in this, then I
> probably won't pursue it very far.  :-) )

I would also prefer the most natural Java class structure
for the respective SQL commands.

Kind regards,
Carl
--
Carl Rosenberger
db4o - database for objects - http://www.db4o.com

 
 
 

1. SQL parser in Java

Please CC: to me when you reply.
---

Folks!

I'd like to know if there is any free or commercial SQL (or OQL)
parser written in Java. It should be able to recognize a relatively
complicated query (say, nested select query). It can be based on other
lex-yacc sort of compiler construction tools -- JLex, JavaCup, JavaCC,
etc.

So far I have found only 'tinySQL' which is very neat but not sufficiently
powerful enough for my purpose.

Thanks in advance.

--
dongwon

2. ESQL/C error?

3. ISO OQL/Datalog/SQL Compiler/Parser to Java

4. Problems with connection to an MS-Access 2.0 database

5. Pdox5 Install Problem

6. ---JAVA-----JAVA-----JAVA-----JAVA-----JAVA-----JAVA-----JAVA-----JAVA---

7. Failure in Data View/Data Environment

8. MSXML parser in Java

9. Anyone use Java Blend yet?

10. Java bibtext parser

11. A string parser for QBE fields (Java clone)?

12. US-DE-JAVA / XERCES PARSER PROGRAMMER / ORACLE