hi there;
i am hope u all still able to catch up about this topic. sorry for delaying for too many days. i was on other application few days back.
well, this morning, when i am back to my thread program. i have found out something interesting.
first of all, i would like to describe again my current program workflow in order to give a clearer picture.
---java thread program---
*** main thread will spawn this child process ***
1.
db connection
2.
// Create a URL pointing to the servlet or CGI script and open an HttpURLConnection on that URL
url = new URL("
HttpURLConnection con = (HttpURLConnection) url.openConnection();
// loop for each of RepID
for (int i=0; i<vRepID.size(); i++) {
[ do insert random id for verification in servlet ]
// pass parameter after get from db to servlet
}
---java thread program---
---java servlet program---
1.
create instance of other class like db connection and report creation
2.
*** in doGet() method ***
a) get all the parameters
b) get db conn here again
c) [ do delete random id for verification ]
d) if successful
proceed to report creation
else
return some error msg
---java servlet program---
Alright, i have done many types of testing.
[1] Testing w/ spawning TOTAL 3 threads simultaneously by generating (all) the reports. (if one of the thread complete, the next thread will be started)
[2] Testing w/ spawning TOTAL 2 threads simultaneously by generating (all) the reports. (if one of the thread complete, the next thread will be started)
[3] Testing w/ spawning TOTAL 1 threads at the time by generating (all) the reports. (if one of the thread complete, the next thread will be started)
[4] Testing w/ spawning TOTAL 1 threads at the time by generating (1) report. (if one of the thread complete, the next thread will be started)
***from test 1-4, some times out of 5 threads (branches), 2 or 3 will receive the server 500 error code.
***error which i printed out from catalina.out
@sql error = 17008 | java.sql.SQLException: Closed Connection
@sql error = 17009 | java.sql.SQLException: Closed Statement
[5] Testing w/ spawning TOTAL 1 threads at the time by generating (1 or more) reports. (if one of the thread complete, the next thread will NOT started)
***test [5] never receive any error after running for multiple times.
FINALLY, i take out the [insertion and deletion random id for verification from the servlet]. now it able to run with NO server 500 error from test [1 - 5].
well, the server 500 error is getting from the servlet because one of this thread must have close the db conn while other thread try to do the [DELETION from db for verification part]
now, my java thread app able to run w/o receiving the server 500 error code. it also able to generate all the reports for all the branches.
however, there are still some minor error which is printed in catalina.out
** sql error = 17008 | java.sql.SQLException: Closed Connection
** sql error = java.lang.NullPointerException QRY: SELECT RPTDESCR FROM SWREP WHERE RPTID = 004
i tried to run this sql from TOAD or SQLPLUS, it does give error but showing the result. i guess this must because of the db conn is closed while some other thread which is running trying to execute the command.
well, it doesnt effect the output report creation and just that i dunno how to avoid from this error.
am i clarify it clearly enough?
Thanks.
rgd/ yoke yew