title: Migrate large mySQL Database to derby using DdlUtils
body: <p>I want to migrate a MySQL database to a Derby-DB using DdlUtils. For that I defined the following ant-script:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;project name="MigrateToDerby" basedir="."&gt;
  &lt;path id="classpath"&gt;
  &lt;fileset dir="./lib"&gt;
    &lt;include name="**/*.jar"/&gt;
  &lt;/fileset&gt;
  &lt;/path&gt;
  &lt;target name="export-source-db" description="Dumps db structure and data"&gt;
  &lt;taskdef name="databaseToDdl" classname="org.apache.ddlutils.task.DatabaseToDdlTask"&gt;
    &lt;classpath refid="classpath"/&gt;
  &lt;/taskdef&gt;
  &lt;databaseToDdl modelName="MigrateTest"&gt;
    &lt;database url="jdbc:mysql://localhost/database" driverClassName="com.mysql.jdbc.Driver" username="a" password="b"/&gt;
    &lt;writeSchemaToFile outputFile="db-schema.xml"/&gt;
    &lt;writeDataToFile outputFile="data.xml"/&gt;
  &lt;/databaseToDdl&gt;
  &lt;/target&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>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 </p>
  
  <blockquote>
    <p>export ANT_OPTS=-Xmx29g</p>
  </blockquote>
  
  <p>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...</p>