Sorry, I wasn't clear about how I'm using DdlUtils. I'm using ant. In my build.xml file the ant target for DdlUtils contains the following.

        <ddlToDatabase>
            <fileset dir="sql">
                <include name="waitlist.xml"/>
            </fileset>

            <database driverClassName="${db1_driverClassName}"
                      url="${db1_url}"
                      username="${db1_username}"
                      password="${db1_password}"
            />

            <writeSchemaToDatabase />

            <writeSchemaSqlToFile
                alterDatabase="false"
                doDrops="false"
                failOnError="true"
                outputFile="sql/waitlist_generated.sql"
            />
        </ddlToDatabase>

When I run it for mysql my build.xml has

    <property
        file="db.properties-mysql"
    />

And when I run it for postgresql I change build.xml so that it has

    <property
        file="db.properties-postgres"
    />

And in the db.properties-<whatever> files are lines like

db1_driverClassName=com.mysql.jdbc.Driver
db1_url=jdbc:mysql://localhost/waitlist

and

db1_driverClassName=org.postgresql.Driver
db1_url=jdbc:postgresql://localhost/waitlist

So it's generating the database specific sql for each one. But for PostgreSQL it's using nextval() with a sequence that hasn't been defined or specified.

I'm guessing that I'm doing something wrong or leaving something out since it's not creating the sequence.

Ok, wait; I commented out the writeSchemaToDatabase and looked at the sql file it generated and the CREATE SEQUENCE is in the sql file. So why is it bombing when it tries to create the tables directly?

Thomas Dudziak wrote:
On 8/22/06, Rusty Wright <[EMAIL PROTECTED]> wrote:

How do I specify an autoincrement column such that the generated sql
works with both mysql and postgresql?  In my database xml file I have

I'm not quite sure what you mean ? The idea of DdlUtils is to specify
the database model in a database-independent XML format and then let
DdlUtils create the database for you or get database-specific SQL for
that XML database schema.
Especially for database creation, every database has different
statements and functionality, so it is quite likely that the SQL
generated for even the simplest database model will only work for the
database that you created the SQL for, and for no other database.

Tom

Reply via email to