Avatar of gustnado
gustnado

asked on 

URGENT: JDBC: Can I close statement before using result set?

In JDBC, if a statement is closed from which a result set was acquired, is the result set still valid?

Context: I have inherited a big java app. At a low level it has a method that creates a statement, does a query returning a result set, and returns the result set. The statement is left dangling (not closed, not referenced) and repeated calls to this are eating up all the memory in a big Informix server. A close on the statement was added to that method to get rid of the statement resource. One connection is used for hundreds of thousands of calls, so these resources accumulate on the connection.

Is it valid to close the statement and then use the result set, or is the result set dependent on the statement still being open?

The database is Informix.
DatabasesJavaOracle Database

Avatar of undefined
Last Comment
CEHJ
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

No, not if the RS was obtained from that Statement
Avatar of gustnado
gustnado

ASKER

CEHJ - what would be the consequences, and do can you specify a source for that info (I have a big wig on the phone who will ask).

Tks
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Actually - i'm suddenly not sure ;-) Did you try it?
Avatar of gustnado
gustnado

ASKER

they are about to, but it is part of a huge system that needs quite a bit of setup.



ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of gustnado
gustnado

ASKER

Yes, now I see that. I assume that close is one of those methods.

Thanks a whole bunch,
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Yes

:-)
Java
Java

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.

102K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo