You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ddlutils-user@db.apache.org by Aj...@us.hsbc.com on 2006/07/06 18:12:00 UTC

write schema to xml generates duplicate columns

I have an embedded Derby 10.1.2.1 database with two schema whose tables are
identical save for the schema name.  Using the following code to write the
DDL to XML generates quite a few duplicated columns.
import org.apache.ddlutils.io.DatabaseIO;
import org.apache.ddlutils.model.Database;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.ddlutils.Platform;
import org.apache.ddlutils.PlatformFactory;
import org.apache.ddlutils.model.Database;

import java.sql.*;

/**
 * This class writes the databae schema to an xml files.
 * @author
 * created June 26, 2006
 * @since
 */
public class WriteDatabaseSchemaToXml
{

   public WriteDatabaseSchemaToXml()
   {
      BasicDataSource dataSource = new BasicDataSource();
      dataSource.setUrl("jdbc:derby:Foo");

dataSource.setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver");

      try
      {
         System.out.println("Starting writing database schema to xml.");
         Database dataBase =  readDatabaseUsingDataSource(dataSource);
         String fileName = "C:\\temp_foo_schema.xml";
         writeDatabaseToXML(dataBase, fileName);
         System.out.println("Finishing writing database schema to xml.");
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }
   public static void main(String[] args)
   {
      new WriteDatabaseSchemaToXml();
   }

   /**
    * Create a Database model using a datasource
    * @param dataSource a data source that is an instance of a
BasicDataSource
    * @return a Database
    */
   public Database readDatabaseUsingDataSource(BasicDataSource dataSource)
   {
      Platform platform =
PlatformFactory.createNewPlatformInstance(dataSource);
      return platform.readModelFromDatabase("TempFOO");
   }

   public void writeDatabaseToXML(Database db, String fileName)
   {
      new DatabaseIO().write(db, fileName);
   }
}

Any suggestions or thoughts appreciated.

Thanks.


-----------------------------------------
******************************************************************
This E-mail is confidential. It may also be legally privileged. If
you are not the addressee you may not copy, forward, disclose or
use any part of it. If you have received this message in error,
please delete it and all copies from your system and notify the
sender immediately by return E-mail.

Internet communications cannot be guaranteed to be timely, secure,
error or virus-free. The sender does not accept liability for any
errors or omissions.
******************************************************************
SAVE PAPER - THINK BEFORE YOU PRINT!


Re: write schema to xml generates duplicate columns

Posted by Thomas Dudziak <to...@gmail.com>.
On 7/6/06, Ajay.Bhala@us.hsbc.com <Aj...@us.hsbc.com> wrote:
>
> I have an embedded Derby 10.1.2.1 database with two schema whose tables are
> identical save for the schema name.  Using the following code to write the
> DDL to XML generates quite a few duplicated columns.

Could you post the SQL definition of the these tables ?

Tom