You have a line in your link that reads:
// if you want to issue multiple queries and/or
// work with multiple result sets, either declare more Statement
// and ResultSet locals above and duplicate all cleanup logic for them,
// or make sure you close each object along the way before you
// try to re-use the reference
I have the following code in one of my data accessing methods:
[same ps and rs instantiating as you]
ps = connection.prepareStatement(query1);
rs = ps.executeQuery();
...[process rs. (I dont close the ps or the rs at this point)]
ps = connection.prepareStatement(query2);
rs = ps.executeQuery();
[catch and finally blocks as you specify]
As you can see I simply reuse the ps and rs variables, without closing them
beforehand. Is this a problem?
The reason this never raised a flag before is because I have another
database accessing method that executes two queries in the same fashion and
it never caused any issues.
Thanks a lot.
On Fri, Sep 16, 2016 at 7:18 PM, Yuval Schwartz <yuval.schwa...@gmail.com>
> Thanks Chris, I'll have a look.
> On Fri, Sep 16, 2016 at 6:41 PM, Christopher Schultz <
> ch...@christopherschultz.net> wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>> On 9/16/16 3:32 AM, Yuval Schwartz wrote:
>> > A few more words/questions on my issue:
>> > My Resource element used the attribute "removeAbandoned" rather
>> > than "removeAbandonedOnBorrow". I have now corrected this. Does
>> > this affect what gets logged (ie: I've had "logAbandoned" on this
>> > whole time but have not seen anything in the logs about abandoned
>> > connections, is it possible that I will now see information about
>> > abandoned threads in my logs)?
>> > "removeAbandonedOnBorrow" doesn't really solve my issue since it
>> > doesn't get to the core of the problem, how will I know to
>> > recognize when an abandoned connection has been removed so that I
>> > can correct the bad code in my application.
>> My bet is on a code path that simply fails to return a connection, or
>> a code path that requests two connections and therefore deadlocks when
>> things get busy.
>> Have a look at this:
>> It might help you track down what's going on.
>> Hope that helps,
>> - -chris
>> -----BEGIN PGP SIGNATURE-----
>> Comment: GPGTools - http://gpgtools.org
>> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>> -----END PGP SIGNATURE-----
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org