On Mon, 19 Aug 2002, Jerry Jalenak wrote:

Chances are you are not releasing your database resources correctly. I may
be wrong, but you should explicitly close your statement, resultset, and
connections using the close() method instead of setting them to null. You
can use the isClosed() method of your connection to check that it really
is being closed.

Plus, it is generally a good idea to close them in a finally clause to
make sure they are closed even when an Exception is thrown.



--> stu: www.stuology.net
It just no longer is plain simple safe fun
when it's the psycho chimp that has the ray gun
------------------------------------------------
Stuology -- A million monkeys can't be wrong


> I hope someone can point me in the right direction on how to resolve the
> following issue.  Our environment is
>
>       Windows NT (Service Pack 5 and 6); have also seen this on Solaris
> 5.8
>       Apache 1.3.26
>       Tomcat 3.3.1
>       Struts 1.1 Beta 2
>       Java 2 SDK 1.4.0_01
>

[cut to preserve space]

>
> QueryRecordAction cleans up the previous set of beans (if they exist), then
> rebuilds the beans and puts the bean back into the session.
>
>       QueryRecordAction
>
>               public class QueryRecordAction extends Action {
>                       PreparedStatement ps = null;
>                       ResultSet rs = null;
>
>                       public ActionForward execute(ActionMapping mapping,
> ActionForm form, HttpServletRequest request, HttpServletResponse response) {
>                               HttpSession session = request.getSession();
>                               if (session.getAttribute("results") != null)
> {
>                                       Results results = (Results)
> session.getAttribute("results");
>                                       results.clear();
>                                       session.removeAttribute("results");
>                               }
>
>                               Results results = new Results();
>
>                               String queryName = (String)
> PropertyUtils.getSimpleProperty(form, "queryName");
>                               try {
>                                       DataSource ds = (DataSource)
> servlet.getServletContext().getAttribute("AEFA");  // key for datasource in
> struts-config
>                                       Connection con = ds.getConnection();
>                                       ps = con.PrepareStatement("SELECT
> name, address from aefa_order where query_name = ?");
>                                       ps.setString(1, queryName);
>                                       rs = ps.executeQuery();
>                                       while(rs.next()) {
>                                               Row row = new Row();
>
> row.setName(rs.getString("name"));
>
> row.setAddress(rs.getString("address"));
>
>                                               results.addRow(row);
>                                       }
>                                       session.setAttribute("results",
> results);
>                                       rs = null;
>                                       ps = null;
>                                       con = null;
>                                       ds = null;
>                               }
>                               catch(Exception e) {
>                                       ActionErrors errors = new
> ActionErrors();
>                                       errors.add("internal_error", new
> ActionError("internal.error", e.getMessage()));
>                                       saveErrors(request, errors);
>                                       return
> (mapping.findForward("error"));
>                               }
>                               return (mapping.findForward("success"));
>                       }
>               }
>
> The "success" forward displays a table of all the rows that were returned.
> Everything works just like I would expect it to, except for Tomcat hanging
> after 15 or 18 queries.  I've been through the code and can't find where I
> would have a memory leak - if anyone can spot one, or has other ideas,
> please let me know!
>
> Thanks!
>
>
> Jerry Jalenak
> Web Publishing
> LabOne, Inc.
> 10101 Renner Blvd.
> Lenexa, KS  66219
> (913) 577-1496
> [EMAIL PROTECTED]
>
>
> This transmission (and any information attached to it) may be confidential and is 
>intended solely for the use of the individual or entity to which it is addressed. If 
>you are not the intended recipient or the person responsible for delivering the 
>transmission to the intended recipient, be advised that you have received this 
>transmission in error and that any use, dissemination, forwarding, printing, or 
>copying of this information is strictly prohibited. If you have received this 
>transmission in error, please immediately notify LabOne at (800)388-4675.
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to