yes i can retrieve tables' names by using APIs of MiddleGen. Unfortunate it doesn't work when running as a servlet. code fragment is pasted below:
Middlegen middlegen = new Middlegen(null);
Database database = new StandardDatabase("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/test", "root", "");
MiddlegenPopulator middlegenPopulator = new MiddlegenPopulator(middlegen, database, "test", "", new HashMap());
// read all regular tables
middlegenPopulator.addRegularTableElements();
middlegenPopulator.populate(middlegen.getTableElements());
//above line will throw an exception of concurrent connection in action of closing connections of database in servlet but it works as a standalone application...
middlegenPopulator.closeConnection();
Iterator it=middlegen.getTables().iterator();
while(it.hasNext()){
Table te=(Table)it.next();
System.out.println(" -table name is:"+te.getTableElement().getName());
}
|