I write a database mid-ware for mysql. I need to determine a sql statement isRead statement or isWrite statement and extract the schema and tables information. Some parser I found through google only parse the DML statement. But I need a parser can parse all statement what mysql server can do.
Do you think that is a good idea I call the mysql parser directly in java or is that possible?
No I don’t think it is a good idea. Calling C / C++ code from Java is rarely a good idea. And in this case, the parser is embedded in a whole bunch of other code, and it is likely to be able separate it out. On top of that, it will emit the parse tree as complicated native data structures that will be difficult to use from Java.
A better approach would be to take an existing open source Java parser for SQL, and (over time) add support for parsing MySQL-specific statements.