If you close the connection first, the statement and result set are invalid. They may or may not get closed depending on your driver. They may or may not throw an exception when you try to close them; also depending on your driver. I advise you not to code that way as the results can be unpredictable.