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 Guy Davis <da...@guydavis.ca> on 2006/02/04 01:33:31 UTC

Oracle 9i generating empty schema file for DatabaseToDdlTask

Hi,

I'm trying to generate a DDL XML file from our current database.  Here's 
my target from build.xml.  The target runs with no errors but the output 
file is empty.  Any ideas?

<target name="db.test">
<taskdef name="db_to_ddl" classpath="../ddlutils/target/classes" 
classname="org.apache.ddlutils.task.DatabaseToDdlTask">
  <classpath>
   <path refid="build.app.classpath" />
     <pathelement location="../ddlutils/target/classes" />
   <path>
   <path>
     <fileset dir="../ddlutils/lib">
      <include name="**/*.jar" />
      <include name="**/*.zip" />
     </fileset>
   </path>
  </classpath>
</taskdef>

<db_to_ddl schema="DV_MASTER">
   <database url="jdbc:oracle:thin:@//INTDB002:1521/INTDEV01"
		driverClassName="oracle.jdbc.driver.OracleDriver"
		username="DV_MASTER" password="password" />
    <writeSchemaToFile outputFile="schema.xml" />
</db_to_ddl>
</target>


Re: Oracle 9i generating empty schema file for DatabaseToDdlTask

Posted by Guy Davis <da...@guydavis.ca>.
Okay, based on the dump-metadata.xml file, I now have my build.xml 
working for dumping the schema and data to XML.  Thanks.

My next step is to try loading this dump from our main Oracle 9 DB into 
an instance of Oracle 10 Express on my workstation.  Here the relevant 
portion of my build.xml:

<taskdef name="ddl_to_db" 
classname="org.apache.ddlutils.task.DdlToDatabaseTask">
  <classpath>
    <path><fileset dir="../ddlutils">
     <include name="lib/*.jar" />
     <include name="dist/*.jar" />
     </fileset></path>
   </classpath>
</taskdef>

<ddl_to_db schemaFile="schema.xml" databaseType="Oracle10">
   <database url="jdbc:oracle:thin:@localhost:1521:XE"
     driverClassName="oracle.jdbc.driver.OracleDriver"
      username="DV_MASTER" password="password" />
     <writeSchemaToDatabase alterDatabase="false" />
</ddl_to_db>

Currently, the DV_MASTER schema on my workstation is completely empty 
and the user has CONNECT and RESOURCE.  The schema.xml file looks 
reasonable now.  It starts with:

<database>
     <table name="DV_AREA">
     ...

When I run a target with this task, I get the following:
C:\Development\trunk\build.xml:451: Could not read schema file 
C:\Development\trunk\schema.xml: The database model has no name

What does "database model has no name" mean?  How do I set one?

Thanks in advance,
Guy


Re: Oracle 9i generating empty schema file for DatabaseToDdlTask

Posted by Thomas Dudziak <to...@gmail.com>.
On 2/6/06, Guy Davis <da...@guydavis.ca> wrote:

> Thanks for the tips Tom.  Unfortunately, I'm still getting an empty
> schema.xml file when using the Ant task.

<snip>

Could you give the dump-metadata.xml build file a try ? Just adapt the
jdbc.properties.oracle9 file in src/test. Be sure to uncomment the
part with the BasicDataSource and comment the one with the oracle data
source, and then invoke it via:

ant -Djdbc.properties.file=src/test/jdbc.properties.oracle9
-Dschemapattern=DV_MASTER -f dump-metadata.xml

This will dump the complete JDBC metadata of the schema. You can also
invoke the dump-model target in this build file, it will dump the
schema in DdlUtils XML format instead.

Tom

Re: Oracle 9i generating empty schema file for DatabaseToDdlTask

Posted by Guy Davis <da...@guydavis.ca>.
Thanks for the tips Tom.  Unfortunately, I'm still getting an empty 
schema.xml file when using the Ant task.  Here's my Ant task now:

	<target name="db.clean" description="Reset the configured database to 
base install.">
		<taskdef name="db_to_ddl" classpath="../ddlutils/target/classes" 
classname="org.apache.ddlutils.task.DatabaseToDdlTask">
			<classpath>
				<path refid="build.app.classpath" />
				<pathelement location="../ddlutils/target/classes" />
				<path>
					<fileset dir="../ddlutils/lib">
						<include name="**/*.jar" />
						<include name="**/*.zip" />
					</fileset>
				</path>
			</classpath>
		</taskdef>

		<db_to_ddl schema="DV_MASTER" databaseType="Oracle9">
			<database url="jdbc:oracle:thin:@//INTDB002:1521/INTDEV01"
				driverClassName="oracle.jdbc.driver.OracleDriver"
				username="DV_MASTER" password="password" />
			<writeSchemaToFile outputFile="schema.xml" />
		</db_to_ddl>
	</target>

I also wrote a short JUnit test that does a similar thing, but this one 
works.  I get the DDL written to the file in schema.xml.  I can't figure 
out what the difference is:

public Database readDatabase(DataSource dataSource)
			throws DynaSqlException, SQLException {
		Platform platform = PlatformFactory
				.createNewPlatformInstance(dataSource);
		return platform.readModelFromDatabase(dataSource.getConnection(), null,
				null, "DV_MASTER", null);
	}

	public void testWriteDb() throws Exception {
		OracleDataSource dataSource = new OracleDataSource();
		dataSource.setURL("jdbc:oracle:thin:@//INTDB002:1521/INTDEV01");
		dataSource.setUser("DV_MASTER");
		dataSource.setPassword("password");

		Database db = readDatabase(dataSource);
		new DatabaseIO().write(db, new FileWriter(new File("schema.xml")));
	}

DDLUtils integration with Ant is what made me give it a try.  I'd really 
like to know what I'm doing wrong with the Ant task...

Thanks,
Guy

Thomas Dudziak wrote:
> On 2/4/06, Guy Davis <da...@guydavis.ca> wrote:
> 
> 
>>I'm trying to generate a DDL XML file from our current database.  Here's
>>my target from build.xml.  The target runs with no errors but the output
>>file is empty.  Any ideas?
> 
> 
> At first glance, this seems to a problem with rights. You should check
> that you have the necessary rights to *see* the tables in the schema
> DV_MASTER.
> With Oracle, it is also helpful to explicitly specify the platform to
> use because there are three different ones (8, 9, 10 with 8 the
> default) that differ. I.e. for an Oracle9 database:
> 
> <db_to_ddl schema="DV_MASTER" databaseType="Oracle9">
> 
> It might also be helpful to run Ant with the -v or the -debug switches
> in order to get more info about the Ant run.
> 
> Tom



Re: Oracle 9i generating empty schema file for DatabaseToDdlTask

Posted by Thomas Dudziak <to...@gmail.com>.
On 2/4/06, Guy Davis <da...@guydavis.ca> wrote:

> I'm trying to generate a DDL XML file from our current database.  Here's
> my target from build.xml.  The target runs with no errors but the output
> file is empty.  Any ideas?

At first glance, this seems to a problem with rights. You should check
that you have the necessary rights to *see* the tables in the schema
DV_MASTER.
With Oracle, it is also helpful to explicitly specify the platform to
use because there are three different ones (8, 9, 10 with 8 the
default) that differ. I.e. for an Oracle9 database:

<db_to_ddl schema="DV_MASTER" databaseType="Oracle9">

It might also be helpful to run Ant with the -v or the -debug switches
in order to get more info about the Ant run.

Tom