Model JDBC databases
We have been working on some scripts that can give you an idea about how to work with Applied Models.
This class converts a jdbc database to a CWM model and is a good example of code generation (although reverse).
This script can be used to visual databases and it can easily be changed to suit different kinds of relational databases.
Usage:
This example requires that the following files are in the classpath: nsmdf.jar, com-appliedmodels-mdf-cwm1_0.jar, mysql-connector-java-3.0.17-ga-bin.jar (get it from MySQL).
JDBC2CWM j2c = new JDBC2CWM();
//Open the connection
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/db","dbuser","password");
//Generate the CWM model
CWMPackage cwmPackage = j2c.generateCWM(con);
//Write the results to a file
XMIWriter writer=((MDFOutermostPackage)cwmPackage).getXMIWriter("1.1"); writer.write((MDFOutermostPackage)cwmPackage, "dbmodelincwm.xml");
con.close();
Download JDBC2CWM.tar.gz
The Model Is the Program!
