*
The moose likes Ant, Maven and Other Build Tools and the fly likes Ant build should fail on java.sql.Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Ant build should fail on java.sql.Exception" Watch "Ant build should fail on java.sql.Exception" New topic
Author

Ant build should fail on java.sql.Exception

Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Hi All,

I am using the following ant script for creating my databases:



Because i am using onerror="abort" It is aborting the ant build if any file produces the sql exception and stop executing that specific sql file.
For example if data3.sql having some err it will abort the ant but data1.sql and data2.sql files have already executed and their results do not roll back.
Is it possible to abort the whole operation rather that aborting the execution of a single sql file.?
What i want is that if any one of the sql files produces sql exception, all files which have already been executed before that file also roll back their output.

If anybody has any idea please help me.

Thanks and Regards,


Khushwinder
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

You currently have set up the task to run three separate transactions. Try placing all of the sql files into a single transaction like this:



JBoss In Action
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Thanks a lot Peter for your reply.

when i am trying to execute like the following :



Its giving me err that

build failed
build.xml:5: only single argument resource collections are supported.


One more thing is that in my rela project my script files are not in a single folder they are in separate folders.
Please suggest me any way out of this problem.

Thanks and Regards,
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Now i am trying to do it like the following :



It is stop executing a specific file's script if it contains any err because autocommit="false" but it does not roll back the results of other script files which have been executed already.
If any body has any idea?
thanks and regards,
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

The error "only single argument resource collections are supported. " tells me that the sql task will not let you span a transaction across multiple SQL source files. So try this: use the concat task to create a temporary file containing all of the SQL sources, give that temp file to the sql task, delete the temp file afterwards.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Ant build should fail on java.sql.Exception
 
Similar Threads
little confusion with appendChild()
Concatenating string texts based of key value
Help required for forEach tag
Jasper Reports with Multiple Datasources
Parsing a text file to an arraylist