Re: Implications of not closing db connection?

From: vivienne wykes (vw011g3667_at_blueyonder.co.uk)
Date: 08/28/04


Date: Fri, 27 Aug 2004 23:28:28 GMT

Thanks Scott,

All this information will assimilate in between long days enjoying the
Edinburgh Festival.

Time out to enjoy a holliday at home...

Cheers
"vivienne wykes" <vw011g3667@blueyonder.co.uk> wrote in message
news:uKkXc.19254$a66.1740@fe2.news.blueyonder.co.uk...
> Hi All,
>
> Could anyone explain simply the implications of not closing a
> resultset,statement, and connection as shown below or provide a link to an
> explanation ?
>
> I had a problem on a shared server (resin) and I think my webapp was
causing
> an issue for other server users by not closing the db connection.
>
> Is it a case of that there is certain amount of connections available to a
> server and not closing the connection ?
>
> Any guidance appreciated.
>
> Regards
>
>
> Code below
>
> <%
> //-------------------make
connection-------------------------------------
>
> Class.forName("org.gjt.mm.mysql.Driver");
> java.sql.Connection connection =
> java.sql.DriverManager.getConnection("jdbc:mysql://localhost/shop");
> java.sql.Statement statement = connection.createStatement();%>
> &nbsp;</td>
> </tr>
> <tr valign="top" class="footer">
> <td height="25" colspan="2" class="bodytext"> <%
> if(session.getAttribute("welcome") != null) { %> <h3> <%=
> session.getAttribute("welcome") %> </h3>
> <%String weddingid=request.getParameter("weddingid");
> if (!weddingid.equals("paulonly")){%>
> Click <a href="<%=
> response.encodeURL("shop-products.jsp?weddingid="+weddingid) %>">here</a>
> to view your wedding pictures
> <%}
> else {%>
> Click <a href="<%=
> response.encodeURL("pauls_jedi_interface.jsp") %>">here</a>
> to enter JEDI
> <%}
> } else { %>
> Please log in below to continue...
> <form action="<%= response.encodeURL("db-result.jsp") %>"
> method="get">
> <table class="bodytext">
> <tr>
> <%java.sql.ResultSet RS3 =
statement.executeQuery("SELECT
> * FROM items ORDER BY weddingid");%>
> <td nowrap>Select Wedding:</td>
> <td><select name="weddings_to_view" class="dropdown"
> onChange="MM_jumpMenu('parent',this,0)">
> <option selected><%=selected%></option>
> <%while(RS3.next()){//open while
> String weddingid2 = RS3.getString("weddingid");
> if (!last_wedding_id.equals(weddingid2)){// open if%>
> <option
>
value="<%=response.encodeURL("db-login.jsp?selected="+weddingid2)%>"><%=wedd
> ingid2%></option>
> <%} //close if
> last_wedding_id = weddingid2;
> }//close while
>
> //-------------------close result set close statement close
> connection-------------------------------------
>
> RS3.close();
> statement.close();
> connection.close();%>
>
>



Relevant Pages

  • Re: Why Would ResponseStream().Read return zero bytes when not at end of file?
    ... there is no network requirement that the number of bytes delivered by the server before closing the connection is identical to the number of bytes the server advertised in the HTTP response. ... The advertised length is just that: an advertisement. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to "kill" a tcp port...
    ... Are you saying there is no way of closing the ... keeps the connection open because the client-side was still ... > 2.TCP itself should give the client an error if the server dies without ... The server process did die (can't see it in Task Manager for any user). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to "kill" a tcp port...
    ... Are you saying there is no way of closing the ... keeps the connection open because the client-side was still ... > 2.TCP itself should give the client an error if the server dies without ... The server process did die (can't see it in Task Manager for any user). ...
    (microsoft.public.dotnet.framework)
  • Re: How to "kill" a tcp port...
    ... Are you saying there is no way of closing the ... keeps the connection open because the client-side was still ... > 2.TCP itself should give the client an error if the server dies without ... The server process did die (can't see it in Task Manager for any user). ...
    (microsoft.public.dotnet.general)
  • Re: Outgoing POP3 email missing/lost/not received
    ... Funny thing is that I have had this ISP for 8 years and it has always been ... It looks like when you last ran CEICW, you set the ISP's mail server to: ... Internet Connection Wizard. ... After the wizard completes, the following network connection ...
    (microsoft.public.windows.server.sbs)