Introduction
DdlUtils is a small, easy-to-use component for working with Database Definition (DDL) files. These are XML files that contain the definition of a database schema, e.g. tables and columns. These files can be fed into DdlUtils via its Ant task or programmatically in order to create the corresponding database or alter it so that it corresponds to the DDL. Likewise, DdlUtils can generate a DDL file for an existing database.
DdlUtils既可以根据定义数据库schema的XML文件(DDL文件)创建或者修改数据库,也可以为现有的数据库生成一个DDL文件。
简单来讲,DdlUtils既是一个library,也是操作数据库schema的Ant tasks。它可以创建和删除数据库,创建、修改和删除表。此外,还可以将XML中定义的数据插入数据库,或者将数据库中的数据读到XML文件中。
DdlUtils追求数据库独立性。schema文件是Turbine XML格式。这种XML格式文件同样用在 Torque 和 OJB 中。
DdlUtils APIs
DdlUtils的核心是定义在org.apache.ddlutils.model中的数据库model,它由表示数据库的schema的各种类组成。
Reading from XML
import org.apache.ddlutils.io.DatabaseIO; import org.apache.ddlutils.model.Database; ... public Database readDatabaseFromXML(String fileName) { return new DatabaseIO().read(fileName); }