| Author |
Ant task
|
Pranav Butala
Greenhorn
Joined: Jan 20, 2004
Posts: 27
|
|
|
Is there a way to write an ant task that will execute MySQL command to create a database and upload a dumpfile in to the created database?
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
See my earlier answer Pranav Butala. If you can do it in SQL, you can do it in Ant, and since the output from mysqldump is valid SQL (for MySQL that is) just use that as your source. Again, look at the documentation for Ant's <sql /> task, in particular the src attribute.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Pranav Butala
Greenhorn
Joined: Jan 20, 2004
Posts: 27
|
|
|
Ant fails to execute the dump file properly as the insert tables have values that contain '--'. This is regognized as comments causing incomplete execution of insert statements.
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
Well yes. If you prefix a line of SQL with '--' it will not be run, since (as you correctly note) this will be interpreted as a comment. However, since we know that mysqldump generates valid SQL to create a DB the problem must be elsewhere - I suspect you need to look at the encoding attribute of Ant's <sql /> task. I'd guess the line breaks are being ignored and your file is being interpreted as one continuous line of SQL. If you want to verify this cut and paste the contents of the mysqldump file into the <sql /> command (using the nested <query /> task, and probably enclosing the whold thing in a CDATA section) and run it that way. If it work, you know the SQL is valid. And it should work. For extra info run ant with the -verbose flag and you'll see the JDBC debug statements.
|
 |
Pranav Butala
Greenhorn
Joined: Jan 20, 2004
Posts: 27
|
|
|
tanks for ur help. Figured out how to call uploads and creation from a bash script.
|
 |
 |
|
|
subject: Ant task
|
|
|