db-ddlutils-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ajay.Bh...@us.hsbc.com
Subject write schema to xml generates duplicate columns
Date Thu, 06 Jul 2006 16:12:00 GMT

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!


Mime
View raw message