I want to migrate a MySQL database to a Derby-DB using DdlUtils. For that I defined the following ant-script:
<?xml version="1.0"?>
<project name="MigrateToDerby" basedir=".">
<path id="classpath">
<fileset dir="./lib">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="export-source-db" description="Dumps db structure and data">
<taskdef name="databaseToDdl" classname="org.apache.ddlutils.task.DatabaseToDdlTask">
<classpath refid="classpath"/>
</taskdef>
<databaseToDdl modelName="MigrateTest">
<database url="jdbc:mysql://localhost/database" driverClassName="com.mysql.jdbc.Driver" username="a" password="b"/>
<writeSchemaToFile outputFile="db-schema.xml"/>
<writeDataToFile outputFile="data.xml"/>
</databaseToDdl>
</target>
</project>
That script works just fine for smaller databases, but fails with a java.lang.OutOfMemoryError: Java heap space for databases with several millions of tuples. Even when I increase memory using
export ANT_OPTS=-Xmx29g
Unfortunately, I can not further increase memory. Is there any other way to migrate the database? I am not sure, why DdlUtils requires so much memory, as the individual tuples are rather small...