Get list of supported DB families:
import org.riverock.dbrevision.db.DatabaseFactory; List<String> list = DatabaseFactory.getSupportedFamilyCode();
Create Database for specific DB:
import java.sql.Connection; import org.riverock.dbrevision.db.Database; import org.riverock.dbrevision.db.DatabaseFactory; Connection conn=null; ... init connection; Database db = DatabaseFactory.getInstance(conn, Database.Family.MYSQL);
Get DB structure - tables, indexes, view without data. Result will be writed to output stream.
import java.io.FileOutputStream; import java.sql.Connection; import org.riverock.dbrevision.db.Database; import org.riverock.dbrevision.db.DatabaseFactory; Connection conn=null; ... init connection; Database db = DatabaseFactory.getInstance(conn, Database.Family.MYSQL); FileOutputStream fileOutputStream = new FileOutputStream("forum-portlet-schema.xml"); DbStructureExport.export(db, fileOutputStream, true);
Get DB structure - tables, indexes, view without data. Result will be writed to output stream.
import java.io.FileOutputStream; import java.sql.Connection; import org.riverock.dbrevision.db.Database; import org.riverock.dbrevision.db.DatabaseFactory; import org.riverock.dbrevision.db.Database; import org.riverock.dbrevision.db.DatabaseFactory; import org.riverock.dbrevision.system.DbStructureImport; import org.riverock.dbrevision.annotation.schema.db.DbSchema; import org.riverock.dbrevision.utils.Utils; Connection conn; ... init connection; String fileName; ... init name of file with DB structure FileInputStream stream = new FileInputStream(fileName); boolean isData; ... init isData. true - import with data, otherwise - w/o data Database db = DatabaseFactory.getInstance(conn, Database.Family.MYSQL); DbStructureImport.importStructure(db, stream, isData);