Ant task to check if a database (connection) exists?
Starting with Ant v 1.8.0 you can use the failOnConnectionError
attribute with the SQL Task.
The description reads as follows:
If false, will only print a warning message and not execute any statement if the task fails to connect to the database.
That looks like it would solve your problem.
Here is a workaround which sets a db.present property (checkpresence.sql is a simple select statement)
<target name="check-db-presence"> <echo message="Checking database presence at: ${db.url}"/> <delete file="tmp/db.present"/> <sql driver="${db.driver}" url="${db.url}" userid="${db.userName}" password="${db.password}" failOnConnectionError="false" onerror="continue" warningproperty="db.empty" errorproperty="db.empty" src="scripts/${db.platform}/checkpresence.sql" print="true" output="tmp/db.present"/> <condition property="db.present"> <available file="tmp/db.present"/> </condition></target>