Re: Implications of not closing db connection?
From: vivienne wykes (vw011g3667_at_blueyonder.co.uk)
Date: 08/28/04
- Next message: Allen Chee: "Re: javax.xml.Parsers location"
- Previous message: Paul Lutus: "Re: rotate() - a Bug?"
- In reply to: vivienne wykes: "Implications of not closing db connection?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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();%>
> </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();%>
>
>
- Next message: Allen Chee: "Re: javax.xml.Parsers location"
- Previous message: Paul Lutus: "Re: rotate() - a Bug?"
- In reply to: vivienne wykes: "Implications of not closing db connection?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|