Statement parsing is quite complicated. Since you need to follow the syntax of that specific implementation. Even those implementation claim to be SQL:2001 compliant for example, for sure there will be considerable differences in the syntax. Thus for a complex and really robust solution, you need to implement yourself the query parser of that RDBMS specific implementation. The full syntax of Oracle query language in BNF notation can be found here:
http://docs.oracle.com/javaee/5/tutorial/doc/bnbuf.html[
^]
This one might be a good starting point:
SQL Parser[
^]