Reputation: 11
I'm learning Java and Eclipse on a Mac. I have an Ant build file in a project that contains sql statements to create a MySql database and tables and insert rows to set up data for the project. I have MySql set up correctly and can use the "mysql" command in terminal with no problem, but when I run the Ant build.xml file in Eclipse, I get: "BUILD FAILED. Cannot run program "mysql": error=2, No such file or directory" I have done the following without success:
I am running:
Thanks for your help!
Here is my build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="publisher" default="all" basedir=".">
<property name="mysql.params" value="-u publisher -ppublisher -D publisher" />
<target name="all" depends="cleandb, createdb, insertdb"></target>
<target name="cleandb">
<exec executable="mysql" input="cleandb.sql">
<arg line="${mysql.params}" />
</exec>
</target>
<target name="createdb">
<exec executable="mysql" input="createdb.sql">
<arg line="${mysql.params}" />
</exec>
</target>
<target name="insertdb">
<exec executable="mysql" input="insertdb.sql">
<arg line="${mysql.params}" />
</exec>
</target>
</project>
Upvotes: 1
Views: 2446
Reputation: 7873
Does it work when you run the Ant build from the command line? If so, its probably the same problem described here:
Upvotes: 2
Reputation: 7873
There's a couple of things I would try:
Set the searchpath attribute to true (it is false by default):
<target name="cleandb">
<exec executable="mysql" input="cleandb.sql" searchpath="true">
<arg line="${mysql.params}" />
</exec>
</target>
Use a nested env element to set the path.
<property environment="env"/>
<exec ... >
<env key="PATH" path="${env.PATH}"/>
</exec>
Upvotes: 0
Reputation: 41287
Any reason not to just be using Ant's SQL task and Connector/J?
In any case, it sounds like you just haven't made sure that that /usr/local/mysql/bin
is available on the PATH
used when executing the Ant build. There's an Environment tab in the Ant build configuration that should allow you to modify the path for the environment Eclipse will run your Ant build file in.
Upvotes: 0