It is impossible to say what happens with the information you provided. You will have to provided better logging schemes to determine what is happening.
Before we can help you will have to find out specifically what exception is happening and when, and what values you are attempting to insert into the db. Check your logs and if they don't tell you what you need then do a better job of collecting the exception information and printing the results to a log file in a manner that can't fail.
All we know is that somewhere in this code:
Something happens. It is impossible to say now because you only catch the general Exception (which is usually a bad idea). So you catch some exception that occurred either before or while the insert to table1 was happening. The result is the catch code gets executed:
So what happens with the log statements? What do they tell you? Then you call the logError() method, so this code happens:
Some more log statements, what do they say in your log files? You get an insert/update to table2, which you don't see, but the update to table3 does succeed. So what happens to the update to table2? It must succeed for the update to table3 to occur. So if you aren't seeing the results in the table2 then one of your assumptions are incorrect. Maybe you are inserting a null value, or maybe you are not calling the update to table2 when you think you are.
Originally posted by Raj Shan:
I have a question with Java threads. If someone helps me out with it, that would be of great help to me.
I have a java code in the following sequence.
try {
servlet call (url call) to external application which makes database calls to its own database schema tables;
check the status of the url call;
if status is ok; continue;
do some database insert or update or delete to table1;
} catch (Exception e) {
some log stmnt;
call logError();
}
logError() {
try {
some log stmnt;
insert / update to table2;
update to table3; (the record is there in table3 for sure for update)
} catch (Exception e) {
some log stmnt;
}
}
Just have a look at the above pseudo code. I have 5 threads running to execute the above stmnts. I have several log stmnts in between. The insert request to table1 is given. somewhere something has happened. I could see no log stmnts in the log file. I could find that the servlet call was successful (bcos the external application has successfully inserted the record in the database) after that I have no clue on what has happened. But I could see that update to table3 is successful. I really dont have the idea of what happened to the insert / update to table 2 and the insert stmnt to table 1. But the insert to table1 didnt happen.
Can somebody help me out with what might have happened? Thanks