agora inbox for pljava-dev@postgresql.org
help / color / mirror / Atom feed[Pljava-dev] Pljava-dev Digest, Vol 26, Issue 8
2+ messages / 0 participants
[nested] [flat]
* [Pljava-dev] Pljava-dev Digest, Vol 26, Issue 8
@ 2006-04-19 08:56
0 siblings, 0 replies; 2+ messages in thread
From: @ 2006-04-19 08:56 UTC (permalink / raw)
pljava-dev-request,hi?
Marek's source code:
> // insert into regional registrations table
> {
> Statement s = connection.createStatement();
>
> ResultSet r = s.executeQuery("SELECT oCarTypeId FROM
>samarapp_data.sapp_cda_pl_cep_rre WHERE oCarTypeId = " + co + " AND
>nCarTypeId = " + cn + " AND nMakeId = " + mk + " AND nModelId = " + mo +
>" AND nDistrictW = " + rw + " AND nDistrictP = " + rp + " AND
>productionYear = " + result.getInt("productionyear") + " AND
>registrationYear = " + result.getInt("registrationyear"));
>
> if (r.next() == false) s.execute("INSERT INTO
>samarapp_data.sapp_cda_pl_cep_rre (oCarTypeId, nCarTypeId, nMakeId,
>nModelId, nDistrictW, nDistrictP, productionYear, registrationYear,
>registrationMonth" + result.getInt("registrationmonth") + ") VALUES (" +
>co + "," + cn + "," + mk + "," + mo + "," + rw + "," + rp + "," +
>result.getInt("productionyear") + "," +
>result.getInt("registrationyear") + "," +
>result.getInt("registrationamount") + ")");
>
> else s.execute("UPDATE samarapp_data.sapp_cda_pl_cep_rre SET
>registrationMonth" + result.getInt("registrationmonth") + "=" +
>result.getInt("registrationamount") + " WHERE oCarTypeId = " + co + "
>AND nCarTypeId = " + cn + " AND nMakeId = " + mk + " AND nModelId = " +
>mo + " AND nDistrictW = " + rw + " AND nDistrictP = " + rp + " AND
>productionYear = " + result.getInt("productionyear") + " AND
>registrationYear = " + result.getInt("registrationyear"));
>
> r.close();
>
> s.close();
> }
When did the result close ? Marek, we can see two ResultSet("result" and "r")in your sourcecode .In the last code ,there is "r.close" to close ResultSet("r") explicitly but i cann't see where the "result" is closed . If you did not close the "result", i guess that it's the error to lead the memory leak.
????????lifeng
????????lifenggod at 263.net
??????????2006-04-19
^ permalink raw reply [nested|flat] 2+ messages in thread
* [Pljava-dev] [SPAM] Re: Pljava\-dev Digest, Vol 26, Issue 8
@ 2006-04-19 09:24
0 siblings, 0 replies; 2+ messages in thread
From: @ 2006-04-19 09:24 UTC (permalink / raw)
lifeng napisa?(a):
> pljava-dev-request,hi?
> When did the result close ? Marek, we can see
> two ResultSet("result" and "r")in your sourcecode .In the last code ,
>there is "r.close" to close ResultSet("r") explicitly but i cann't see where
> the "result" is closed . If you did not close the "result", i guess that it's the
> error to lead the memory leak.
Well, result is a ResultSet of the main query:
Connection connection =
DriverManager.getConnection("jdbc:default:connection");
Statement statement = connection.createStatement();
ResultSet result;
statement.execute("...");
result = statement.getResultSet();
while (result.next()) {
...
}
result.close();
statement.close();
So as you can see it will be closed after last row.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2006-04-19 09:24 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-04-19 08:56 [Pljava-dev] Pljava-dev Digest, Vol 26, Issue 8
2006-04-19 09:24 [Pljava-dev] [SPAM] Re: Pljava\-dev Digest, Vol 26, Issue 8
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox