Does anyone know whether there is a java library for parsing a MySQL schema? In code I want to be able to determine the tables and fields specified in a schema. Or will I need to write my own?
Thanks Richard.
Edit: Just want to avoid re-inventing the wheel unnecessarily 🙂
Answering my own question:
Am using jsqlparser http://jsqlparser.sourceforge.net/
This parses individual statements, not multiple statements such as found in a schema. So split the schema on ‘;’. It also doesn’t like the ‘`’ character, so these need to be stripped out. Code to get column names for a particular table: