The invention discloses a configurable method for automatically generating a
database and accessing data. The configurable method includes converting a UML (
unified modeling language) class image designed in a business requirement analysis stage into an
XML (
extensible markup language) file; generating
metadata information by means of analyzing and reading the
XML file; selecting a used
database and used business
processing language by means of selecting a configuration file by a user; generating a
database template, an entity class template and a
data access class template; and generating a database, an entity class and a
data access class of a
system by the aid of a generator of the
system according to the
metadata information and the generated templates. The
metadata information includes basic attributes including the
accessibility, the name and the type of an object. By the aid of the configurable method, the UML class image is converted to the database, the entity class, the
data access class and the like, accordingly, the database and a
data access layer can adapt to change of the object and change of the attributes of the object, when the type of the database and the business
processing language are changed, only the design of the UML class image needs to be modified to regenerate a database and a
data access layer, and
extensibility and
maintainability of the
system are improved.