Now Suppose there is exceptiopn in line 3.I can catch the exception but how to commit which ever is already excuted i mean suppose there is a task which i am creating in the line 2 i want that to commit even though there is a exception in line 3....
Do you mean "commit" as in the DB sense of the word? That could be achieved by keeping several savepoints within an overall transaction. Or you could just use several transactions, maybe one for each step.
sorry not in the DB sense in the in the java whatever i have wriiten in line2 gets executed even though there is an exception in line 3...can it be achieved
I don't follow - by the time line 3 is executed, line 2 has already been executed. You just need to ensure that whatever needs to be persisted that happens in line 2 does get persisted before moving on.
No the exception is getting thrown the transaction is getting rolled back so whatever is written in line 2 is getting rolledback....i dont how but its doing that...i have debugged the application and seen and for the same scenario i have written the JUNIt and its getting failed because of this
If i am registering a person it makes multiple enteries to different table approx 90 tables....however the frameework is designed in such a way that if there is an exception then all the transactions should rolled back nothing should go in the table...but i require that one piece of code should get executed no matter what the exception is thrown or not
I'm confused (and, I suspect, so are you :-) I asked specifically if this was about DB transaction, which you said it was not. So please clarify what this "transaction" is that gets "rolled back" and which deals with "tables" - that sounds very much like a DB.
Are you talking about git or subversion source control? Cause if you are, the answer is:
If you have an exception, don't commit the code. End of story. Don't make other people deal with your mistakes, fix them before you push the code.
Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry.
Free, earth friendly heat - from the CodeRanch trailboss