pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Creating a database using ant
3+ messages / 3 participants
[nested] [flat]

* Creating a database using ant
@ 2005-11-21 04:24 Nathan McEachen <nathan@mceachen.us>
  2005-11-21 05:19 ` Re: Creating a database using ant Jan de Visser <jdevisser@digitalfairway.com>
  2005-11-21 06:38 ` Re: Creating a database using ant Oliver Jowett <oliver@opencloud.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Nathan McEachen @ 2005-11-21 04:24 UTC (permalink / raw)
  To: pgsql-jdbc

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





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Creating a database using ant
  2005-11-21 04:24 Creating a database using ant Nathan McEachen <nathan@mceachen.us>
@ 2005-11-21 05:19 ` Jan de Visser <jdevisser@digitalfairway.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Jan de Visser @ 2005-11-21 05:19 UTC (permalink / raw)
  To: pgsql-jdbc

On Sunday 20 November 2005 23:24, Nathan McEachen wrote:
> Although autocommit is false, it looks like the sql script is still
> executing within a transaction.  Does anyone know a workaround?

You got it the wrong way around. autocommit=false gets you a transaction, i.e. 
statements are *not* automatically committed when you have that set. You want 
autocommit=true. I've done it (creating databases in ant) and it works...

JdV!!

-- 
--------------------------------------------------------------
Jan de Visser                     jdevisser@digitalfairway.com

                Baruk Khazad! Khazad ai-menu!
--------------------------------------------------------------



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Creating a database using ant
  2005-11-21 04:24 Creating a database using ant Nathan McEachen <nathan@mceachen.us>
@ 2005-11-21 06:38 ` Oliver Jowett <oliver@opencloud.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Oliver Jowett @ 2005-11-21 06:38 UTC (permalink / raw)
  To: Nathan McEachen <nathan@mceachen.us>; +Cc: pgsql-jdbc

Nathan McEachen wrote:

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

>            autocommit="false"             

Try with autocommit="true".

-O



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2005-11-21 06:38 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-11-21 04:24 Creating a database using ant Nathan McEachen <nathan@mceachen.us>
2005-11-21 05:19 ` Jan de Visser <jdevisser@digitalfairway.com>
2005-11-21 06:38 ` Oliver Jowett <oliver@opencloud.com>

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