You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by M Damon Hill <hw...@yahoo.com> on 2003/05/21 22:02:29 UTC

perplexing exec mysql problem

good day...
 
I have been working on this now for a couple of hours and can't seem to see the problem with the code. A little help from some extra eyes would be very appreciative.
 
I am trying to create a database in mysql and then execute some sql scripts on the newly created database. All of this of course done using the <exec> task. Here is the code for a couple of the targets in the build.xml:
 

<target name="init_db"><!--depends="transform_default_project"-->
  <exec executable="mysqladmin" output="createDB.output">
      <arg line="create ${project.db.name}"/>
  </exec>
  <antcall target="sql_script_1"/>
</target>



<target name="sql_script_1">
  <exec executable="mysql" output="initDB.output">
    <arg line="${project.db.name} &lt; ${sql.dir}/${sql1}"/>
  </exec>
  <antcall target="sql_script_2"/>
</target>



<target name="sql_script_2">
  <exec executable="mysql" output="initDB.output">
    <arg line="${project.db.name} &lt; ${sql.dir}/${sql2}"/>
  </exec>
  <antcall target="sql_script_3"/>
</target>

Now as you can tell the script will first use mysqladmin to create the database. That particular task executes just fine and creates the databse with no problems. However, whenever I run the second target, in this case sql_script_1, it does not update the database and the resulting exec returns a 1. 

I can run the same command from the command line on the machine I am testing this script on and it works properly. The command is:
       mysql project.db.name < path_to_script/sql1

This works fine like I say from the command line but not from inside ant.

Anyone have any thoughts or suggestions for this?? Seen anything like it before??

Thanks in advance!

damon



---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

Re: perplexing exec mysql problem

Posted by Douglas Guptill <dg...@accesswave.ca>.
On Thu, May 22, 2003 at 09:01:30AM -0700, M Damon Hill wrote:
> Douglas--
>  
> Thanks for the suggestion, however, still to no avail. Here are my two tasks I am running:
>  
> 
> <target name="init_db">  
>     <exec executable="mysqladmin" output="createDB.output">
>          <arg line="-hlocalhost -ufrodo -pring create ${project.db.name}"/>
>     </exec>
>     <antcall target="test_sql"/> 
> </target>
> 
> <target name="test_sql">
>    <sql driver="org.gjt.mm.mysql.Driver" 
>           url="jdbc:mysql://localhost/{$project.db.name}" 
>           userid="root" 
>           password="" 
>           src="${sql.dir}/${sql1}"  
>           print="yes" 
>           output="sql1.output"/>
> </target>
> 
> The result from running this init_db target is as follows:
> 
> [root@machine]# ant -Dproject.db.name=damon_test init_db
> Buildfile: build.xml
> 
> init_db:
> 
> test_sql:
> 
> BUILD FAILED
> file:/usr/local/new_project/build.xml:259: java.sql.SQLException: Invalid authorization specification: Access denied for user: 'root@machine' (Using password: NO)
> 
> Total time: 38 seconds
> [root@machine]#
> 
> See anything that I am missing?? I am sure it is blatantly obvious.

1. Never, never, never do anything before setting the root password.

2. Once you have set the root password, try what you have again.
   The output "Using password: NO" is slightly mystifying, since you
   have specified a password.

3. MySql is VERY fussy about access privileges.  You may have to check 
   the "user" and "db" databases as root,  to ensure that you have 
   granted your user appropriate access privileges.   The MySQL
   manual is long, however a quick look at the table of contents is
   mandatory.  Look for "The MySQL Access Privilege System".

Hpe that helps,
Doug.


Re: perplexing exec mysql problem

Posted by M Damon Hill <hw...@yahoo.com>.
Douglas--
 
Thanks for the suggestion, however, still to no avail. Here are my two tasks I am running:
 

<target name="init_db">  
    <exec executable="mysqladmin" output="createDB.output">
         <arg line="-hlocalhost -ufrodo -pring create ${project.db.name}"/>
    </exec>
    <antcall target="test_sql"/> 
</target>

<target name="test_sql">
   <sql driver="org.gjt.mm.mysql.Driver" 
          url="jdbc:mysql://localhost/{$project.db.name}" 
          userid="root" 
          password="" 
          src="${sql.dir}/${sql1}"  
          print="yes" 
          output="sql1.output"/>
</target>

The result from running this init_db target is as follows:

[root@machine]# ant -Dproject.db.name=damon_test init_db
Buildfile: build.xml

init_db:

test_sql:

BUILD FAILED
file:/usr/local/new_project/build.xml:259: java.sql.SQLException: Invalid authorization specification: Access denied for user: 'root@machine' (Using password: NO)

Total time: 38 seconds
[root@machine]#

See anything that I am missing?? I am sure it is blatantly obvious.

Thanks again for the help and suggestions.

Cheers,
~damon



Douglas Guptill <dg...@accesswave.ca> wrote:
On Thu, May 22, 2003 at 06:19:28AM -0700, M Damon Hill wrote:
> Antoine--
> 
> Thanks for the tips. I am now using the task however, a little problem with that particular task and maybe it is rooted in my very little experience with databases in general. However, here is the situation.
> 
> I am able to successfully create the new database with the 'mysqladmin' command line tool using the create command. However, that simply creates an "empty" database. Now the sql scripts that I am wanting to execute on the newly created database, contain all of the information to "populate" this database with tables, values, users, and what not. Now, the problem with that as you can probably guess is, when I execute the the script on the database and it wants a userid and pass, well I don't have one yet, because the database is clean and prestine.
> 
> Are that any suggestions as to a way around this issue?

Use the sql task, specify user root, use src attribute to point to
sql that creates a new user.

Doug.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

Re: perplexing exec mysql problem

Posted by Douglas Guptill <dg...@accesswave.ca>.
On Thu, May 22, 2003 at 06:19:28AM -0700, M Damon Hill wrote:
> Antoine--
>  
> Thanks for the tips. I am now using the <sql> task however, a little problem with that particular task and maybe it is rooted in my very little experience with databases in general. However, here is the situation.
>  
> I am able to successfully create the new database with the 'mysqladmin' command line tool using the create command. However, that simply creates an "empty" database. Now the sql scripts that I am wanting to execute on the newly created database, contain all of the information to "populate" this database with tables, values, users, and what not. Now, the problem with that as you can probably guess is, when I execute the the <sql> script on the database and it wants a userid and pass, well I don't have one yet, because the database is clean and prestine.
>  
> Are that any suggestions as to a way around this issue?

Use the sql task, specify user root, use src attribute to point to
sql that creates a new user.

Doug.

Re: perplexing exec mysql problem

Posted by Antoine Levy-Lambert <le...@tiscali-dsl.de>.
I do not know mysql; maybe with mysqladmin you can create your first user
and password ?
Antoine
----- Original Message -----
From: "M Damon Hill" <hw...@yahoo.com>
To: "Ant Users List" <us...@ant.apache.org>
Sent: Thursday, May 22, 2003 3:19 PM
Subject: Re: perplexing exec mysql problem


> Antoine--
>
> Thanks for the tips. I am now using the <sql> task however, a little
problem with that particular task and maybe it is rooted in my very little
experience with databases in general. However, here is the situation.
>
> I am able to successfully create the new database with the 'mysqladmin'
command line tool using the create command. However, that simply creates an
"empty" database. Now the sql scripts that I am wanting to execute on the
newly created database, contain all of the information to "populate" this
database with tables, values, users, and what not. Now, the problem with
that as you can probably guess is, when I execute the the <sql> script on
the database and it wants a userid and pass, well I don't have one yet,
because the database is clean and prestine.
>
> Are that any suggestions as to a way around this issue?
>
> Thanks for all the help.
>
> ~damon
>
> Antoine Levy-Lambert <le...@tiscali-dsl.de> wrote:
> 2 tips :
> - use ant 1.6alpha (nightly builds) . ant 1.6 has an input attribute for
> exec, indicating a file from which standard input is taken,
> - even better : try to use the task instead of the task to
> run your DDL or DML scripts.
> can connect directly to the database (through JDBC driver) and
> execute whatever SQL statements you want.
> Antoine
> ----- Original Message -----
> From: "M Damon Hill"
> To:
> Sent: Wednesday, May 21, 2003 10:02 PM
> Subject: perplexing exec mysql problem
>
>
> > good day...
> >
> > I have been working on this now for a couple of hours and can't seem to
> see the problem with the code. A little help from some extra eyes would be
> very appreciative.
> >
> > I am trying to create a database in mysql and then execute some sql
> scripts on the newly created database. All of this of course done using
the
> task. Here is the code for a couple of the targets in the build.xml:
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Now as you can tell the script will first use mysqladmin to create the
> database. That particular task executes just fine and creates the databse
> with no problems. However, whenever I run the second target, in this case
> sql_script_1, it does not update the database and the resulting exec
returns
> a 1.
> >
> > I can run the same command from the command line on the machine I am
> testing this script on and it works properly. The command is:
> > mysql project.db.name < path_to_script/sql1
> >
> > This works fine like I say from the command line but not from inside
ant.
> >
> > Anyone have any thoughts or suggestions for this?? Seen anything like it
> before??
> >
> > Thanks in advance!
> >
> > damon
> >
> >
> >
> > ---------------------------------
> > Do you Yahoo!?
> > The New Yahoo! Search - Faster. Easier. Bingo.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
> ---------------------------------
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.


Re: perplexing exec mysql problem

Posted by M Damon Hill <hw...@yahoo.com>.
Antoine--
 
Thanks for the tips. I am now using the <sql> task however, a little problem with that particular task and maybe it is rooted in my very little experience with databases in general. However, here is the situation.
 
I am able to successfully create the new database with the 'mysqladmin' command line tool using the create command. However, that simply creates an "empty" database. Now the sql scripts that I am wanting to execute on the newly created database, contain all of the information to "populate" this database with tables, values, users, and what not. Now, the problem with that as you can probably guess is, when I execute the the <sql> script on the database and it wants a userid and pass, well I don't have one yet, because the database is clean and prestine.
 
Are that any suggestions as to a way around this issue?
 
Thanks for all the help.
 
~damon

Antoine Levy-Lambert <le...@tiscali-dsl.de> wrote:
2 tips :
- use ant 1.6alpha (nightly builds) . ant 1.6 has an input attribute for
exec, indicating a file from which standard input is taken,
- even better : try to use the task instead of the task to
run your DDL or DML scripts.
can connect directly to the database (through JDBC driver) and
execute whatever SQL statements you want.
Antoine
----- Original Message -----
From: "M Damon Hill" 
To: 
Sent: Wednesday, May 21, 2003 10:02 PM
Subject: perplexing exec mysql problem


> good day...
>
> I have been working on this now for a couple of hours and can't seem to
see the problem with the code. A little help from some extra eyes would be
very appreciative.
>
> I am trying to create a database in mysql and then execute some sql
scripts on the newly created database. All of this of course done using the
task. Here is the code for a couple of the targets in the build.xml:
>
>
> 
> 
> 
> 
> 
> 
>
>
>
> 
> 
> 
> 
> 
> 
>
>
>
> 
> 
> 
> 
> 
> 
>
> Now as you can tell the script will first use mysqladmin to create the
database. That particular task executes just fine and creates the databse
with no problems. However, whenever I run the second target, in this case
sql_script_1, it does not update the database and the resulting exec returns
a 1.
>
> I can run the same command from the command line on the machine I am
testing this script on and it works properly. The command is:
> mysql project.db.name < path_to_script/sql1
>
> This works fine like I say from the command line but not from inside ant.
>
> Anyone have any thoughts or suggestions for this?? Seen anything like it
before??
>
> Thanks in advance!
>
> damon
>
>
>
> ---------------------------------
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

Re: perplexing exec mysql problem

Posted by Antoine Levy-Lambert <le...@tiscali-dsl.de>.
2 tips :
- use ant 1.6alpha (nightly builds) . ant 1.6 has an input attribute for
exec, indicating a file from which standard input is taken,
- even better : try to use the <sql/> task instead of the <exec/> task to
run your DDL or DML scripts.
<sql/> can connect directly to the database (through JDBC driver) and
execute whatever SQL statements you want.
Antoine
----- Original Message -----
From: "M Damon Hill" <hw...@yahoo.com>
To: <us...@ant.apache.org>
Sent: Wednesday, May 21, 2003 10:02 PM
Subject: perplexing exec mysql problem


> good day...
>
> I have been working on this now for a couple of hours and can't seem to
see the problem with the code. A little help from some extra eyes would be
very appreciative.
>
> I am trying to create a database in mysql and then execute some sql
scripts on the newly created database. All of this of course done using the
<exec> task. Here is the code for a couple of the targets in the build.xml:
>
>
> <target name="init_db"><!--depends="transform_default_project"-->
>   <exec executable="mysqladmin" output="createDB.output">
>       <arg line="create ${project.db.name}"/>
>   </exec>
>   <antcall target="sql_script_1"/>
> </target>
>
>
>
> <target name="sql_script_1">
>   <exec executable="mysql" output="initDB.output">
>     <arg line="${project.db.name} &lt; ${sql.dir}/${sql1}"/>
>   </exec>
>   <antcall target="sql_script_2"/>
> </target>
>
>
>
> <target name="sql_script_2">
>   <exec executable="mysql" output="initDB.output">
>     <arg line="${project.db.name} &lt; ${sql.dir}/${sql2}"/>
>   </exec>
>   <antcall target="sql_script_3"/>
> </target>
>
> Now as you can tell the script will first use mysqladmin to create the
database. That particular task executes just fine and creates the databse
with no problems. However, whenever I run the second target, in this case
sql_script_1, it does not update the database and the resulting exec returns
a 1.
>
> I can run the same command from the command line on the machine I am
testing this script on and it works properly. The command is:
>        mysql project.db.name < path_to_script/sql1
>
> This works fine like I say from the command line but not from inside ant.
>
> Anyone have any thoughts or suggestions for this?? Seen anything like it
before??
>
> Thanks in advance!
>
> damon
>
>
>
> ---------------------------------
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.


Re: perplexing exec mysql problem

Posted by Douglas Guptill <dg...@accesswave.ca>.
On Wed, May 21, 2003 at 01:02:29PM -0700, M Damon Hill wrote:
> good day...
>  
> I have been working on this now for a couple of hours and can't seem to see the problem with the code. A little help from some extra eyes would be very appreciative.
>  
> I am trying to create a database in mysql and then execute some sql scripts on the newly created database. All of this of course done using the <exec> task. Here is the code for a couple of the targets in the build.xml:
>  

...<snip>...

I have good success using the <sql> task.  The "src" attribute specifies
a file with sql in it.

Doug.