Apache DdlUtils is what I need. When I search about crossdb, I find it, and it is very useful, but powerful. It can generate a database from scratch, just with parameters. Or it can capture existing database table definitions as well as index definitions. You can use the delimiter if you want (it is very important for me to use Apache Derby). You can simply print these definitions or apply them directly to the source database (I have not tried the second yet). It converts definitions for the selected database. But one big problem is that there is no good tutorial on how to start using it. I looked through the packages to find a good place to start. Here is what I have achieved, the sample code to create a complete database table creates sql.
DerbyPlatform dp = new DerbyPlatform(); dp.setDelimitedIdentifierModeOn(true); Database dbs = new Database(); DerbyModelReader dmr = new DerbyModelReader(dp); Database test = dmr.getDatabase(conn, "MyDBTest"); DerbyBuilder db = new DerbyBuilder(dp); String testSqlDerby = dp.getCreateTablesSql(test, true, true); System.out.println(testSqlDerby); System.out.println("\n\n\n\n"); MySql50Platform mp = new MySql50Platform(); mp.setDelimitedIdentifierModeOn(true); MySqlBuilder mb = new MySqlBuilder(mp); String testSqlMysql = mp.getCreateTablesSql(test, true, true); System.out.println(testSqlMysql);
source share