pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan McEachen <nathan@mceachen.us>
To: pgsql-jdbc@postgresql.org
Subject: Creating a database using ant
Date: Sun, 20 Nov 2005 21:24:07 -0700
Message-ID: <43814BE7.1090507@mceachen.us> (raw)

Hello,

I am trying to write get ant to drop and create a database.  I tried to 
use the sql task but recieved the following error:

java.sql.SQLException: ERROR: DROP DATABASE cannot run inside a 
transaction block

Here is my ant task:

        <sql driver="${db.postgresql.driver}"
            userid="${rootuser}"  
            password="${rootpassword}"
            url="${db.postgresql.url}"
            onerror="stop"
            autocommit="false"  
            src="${db.postgresql.sqlScripts.dir}/dropDatabase.sql">
            <classpath>
                <path refid="run.classpath"/>  
            </classpath>  
        </sql>

Although autocommit is false, it looks like the sql script is still 
executing within a transaction.  Does anyone know a workaround?

I also tried runing the dropdb command directly, but (from my 
understanding) ant cannot receive user input during execution.  As a 
result, I can't supply a password to dropdb (at least I don't know how 
to do it).

        <exec executable="${postgres_bin.dir}/dropdb"
              failonerror="true">
          <arg value="-U"/>
          <arg value="${rootuser}"/>
          <arg value="--password"/>
          <arg value="mydb"/>
        </exec>

Many thanks,

-Nathan

-- 
In theory, there is no difference between theory and practice.  But, in practice, there is.

--Jan L.A. van de Snepscheut





view thread (3+ messages)  latest in thread

Message-ID: <43814BE7.1090507@mceachen.us>
Permalink:  ../43814BE7.1090507@mceachen.us/
Also on:    postgresql.org/message-id/43814BE7.1090507@mceachen.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: nathan@mceachen.us
  Subject: Re: Creating a database using ant
  In-Reply-To: <43814BE7.1090507@mceachen.us>
  References: <43814BE7.1090507@mceachen.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox