When running a Java application, the following error occurs.
Org. logicalcobwebs. proxool. Housekeeper sweep
Warning: #0002 was active for 634297 milliseconds and has been removed automaticaly. the thread responsible was named 'HTTP-8080-1 ', but the last SQL it timed med is unknown because the trace property is not enabled.
Error code:
Try {<br/> conn = connect (); <br/> stmt = Conn. createstatement (); <br/> rs = stmt.exe cutequery (SQL); <br/> while (RS. next () {// error message <br/> to = Rs. getstring ("emailto "). trim (); <br/> body = Rs. getstring ("emailbody"); <br/> subject = Rs. getstring ("emailsubject"); <br/> from = Rs. getstring ("emailfrom "). trim (); <br/> cc = Rs. getstring ("emailcc "). trim (); <br/> send (subject, body, to, CC, BCC, from, AU) <br/>}< br/>} catch (sqlexception E) {<br/> errorlog. log ("Get send message exception. /n "+ E. getmessage (), logfile); <br/> // throw E; <br/>}finally {<br/> close (RS, stmt, Conn ); <br/>}
Analysis:
According to the prompt, the database connection in the program is not released. The connection may not be released before the SQL statement is executed. Check, the program gets and uses the connection is not uncommon, no problem found after the check. At the same time, there is no excessive connection to get getconnect ().
Continue to pay attention to the output information and find that the Rs. Next () line has an error, but not every line has an error. An exception occurs only when the number of loops reaches about 7th. Is connection timeout? Check the configuration file. The connection timeout time is 5 seconds, which is basically the same as that in 7 cycles. Set the timeout time to a large value, and the error occurrence time is postponed in turn. Set it to enough time for loop completion. The exception disappears.
Cause:
The connection is closed in time. But this is a superficial reason. The underlying reason is that
The maximum-active-time configured in proxool takes effect not only for idle connections, but also for active connections. This may force the connection in the activity to close.
Solution:
This type of problem needs to be checked from these aspects:
1. Whether a connection is closed in time after use.
2. getconnection () is performed multiple times for a connection.
3. Check the difference between the execution time of the connection in the error message and the maximum-active-Time Value in the proxool configuration file. Increase the value as appropriate. If a connection operation takes a long time, you can use a temporary variable to shorten the connection operation time. In the above example, you can define a string array for storage, and then use loops to process these strings.