When I have an ant task like:
---------------------------------
<target name="export-db-postgres" description="Dumps db structure and data">
<taskdef name="databaseToDdl"
classname="org.apache.ddlutils.task.DatabaseToDdlTask">
<classpath refid="classpath"/>
</taskdef>
<databaseToDdl modelName="MigrateTest" schema="postgres">
<database url="jdbc:postgresql://localhost:5432/izemail"
driverClassName="org.postgresql.Driver" username="test" password="test"/>
<writeSchemaToFile outputFile="db-schema.xml"/>
<writeDtdToFile outputFile="db-schema.dtd"/>
<writeDataToFile outputFile="db-data.xml"/>
</databaseToDdl>
</target>
---------------------------------
I get the following error when running it:
---------------------------------
Buildfile: build.xml
export-db:
BUILD FAILED
C:\Temp\DdlUtils-test\build.xml:53: The <databaseToDdl> type doesn't support
the "schema" attribute.
Total time: 3 seconds
---------------------------------
But if I look at the ant documentation it says that the DatabaseToDdlTask does
support this attribute. It would be nice if it is supported so you could
exclude/include tables from export. (Or at least I thought that this attribute
could do this for me). See below the ant documentation:
---------------------------------
DatabaseToDdlTask reference
Class name: org.apache.ddlutils.task.DatabaseToDdlTask
This is the container for sub tasks that operate in the direction database ->
file, eg. that create/drop a schema in the database, insert data into the
database. They also create DTDs for these data files, and dump the SQL for
creating a schema in the database to a file.
Attribute Required? Possible values Default value Meaning
catalog no depends on the database Specifies the catalog(s) to access.
This is only necessary for some databases. The pattern is that of
java.sql.DatabaseMetaData#getTables. The special pattern '%' indicates that
every catalog shall be used.
databaseType no axion, cloudscape, db2, derby, firebird, hsqldb,
interbase, maxdb, mckoi, mssql, mysql, mysql5, oracle, oracle9, oracle10,
postgresql, sapdb, sybase The database type. You should only need to specify
this if DdlUtils is not able to derive the setting from the name of the used
jdbc driver or the jdbc connection url. If you need to specify this, please
post your jdbc driver and connection url combo to the user mailing list so that
DdlUtils can be enhanced to support this combo.
modelName no Specifies the name of the model, e.g. the value of the
name attribute in the XML if the writeSchemaToFile sub-task is used. If none is
given, DdlUtils will use the schema name as returned by the database, or
"default" if the database returned no schema name.
schema no depends on the database Specifies the table schema(s) to
access. This is only necessary for some databases. The pattern is that of
java.sql.DatabaseMetaData#getTables. The special pattern '%' indicates that
every table schema shall be used.
tableTypes no TABLE Specifies the table types to processed. For details
and typical table types see java.sql.DatabaseMetaData#getTables. Per default,
only tables of type TABLE, eg. user tables, are processed.
useDelimitedSqlIdentifiers no true, false false Whether DdlUtils shall
use delimited (quoted) identifiers (table names, column names etc.) In most
databases, undelimited identifiers will be converted to uppercase by the
database, and the case of the identifier is ignored when performing any SQL
command. Undelimited identifiers can contain only alphanumerical characters and
the underscore. Also, no reserved words can be used as such identifiers.
The limitations do not exist for delimited identifiers. However case of
the identifier will be important in every SQL command executed against the
database.
---------------------------------
Igor