Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9052125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:05:18+00:00 2026-06-16T13:05:18+00:00

I know the safe pattern in Java is to close your ResultSet, Statement, and

  • 0

I know the safe pattern in Java is to close your ResultSet, Statement, and Connection in order in a finally block.

If you close connection and then try to close statement(doesnt throw exception). But if you try to call any method from statement an exception is thrown.

I was wondering does closing connection automatically close all the statement objects created out of that connection?

Update:
I am using DatabaseProductVersion: Oracle Database 11g Release 11.1.0.0.0
DriverName: Oracle JDBC driver
DriverVersion: 10.2.0.4.0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:05:20+00:00Added an answer on June 16, 2026 at 1:05 pm

    Yes it does, Connection.close API says “Releases this Connection object’s database and JDBC resources immediately instead of waiting for them to be automatically released”. The problem is that applications typically use database connection pools and these may simply return Connection to pool on Connection.close.

    In any case, it’s a good practice to always close ResultSet and Statement explicitly and not to rely on Connection.close.

    Besides, it’s not the best idea to work with JDBC directly. You can use Spring JDBC instead and forget about releasing resources problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know which is safe & better way to use Connection variable
I'm familiar with the try{}finally{} pattern, the using(){} pattern as ways to ensure Dispose()
Suppose you have a module that you know is safe. You want to mark
I know it's safe to draw on any thread so long as I call
I know UIView are not thread safe so i cant add a view on
Do you know any way for safe copy cut operation in Android? I want
So I know NSManagedObjects are not thread safe, and the best way to get
I need to know if it's safe to create a static Regex object like
I want to know if my code is safe and if there are other
Is it safe to left task unreferenced if i know for sure that it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.