2

Is there any method to create postgresql database unsing ant?

I put an SQL creation statement inside a sql Task:

<sql
driver="${driver}"
url="${url}"
userid="${userid}"
password="${password}"
autocommit="true">
CREATE DATABASE ${project};
</sql> 

there is no exception but the database is not created.

Does anyone have any idea how to fix this?

1

1 Answer 1

4

Must be something with your environment, the following works for me:

<?xml version="1.0" encoding="utf-8"?>
<project basedir="." default="create-db" name="SOTest">
    <target name="create-db">
       <sql driver="org.postgresql.Driver"
            classpath="postgresql-9.0-801.jdbc4.jar"
            url="jdbc:postgresql://localhost/template1"
            userid="postgres"
            password="secretpassword"
            autocommit="true">

         CREATE DATABASE sampledb;
       </sql>
    </target>

</project>

To which database are you connecting in your JDBC url?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.