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

  • SEARCH
  • Home
  • 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 8415975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:36:22+00:00 2026-06-10T01:36:22+00:00

QUESTION: can YOU use multiple statements and recordset, which operate simultaneously, using the same

  • 0

QUESTION: can YOU use multiple statements and recordset, which operate simultaneously, using the same connection in a non MULTI THREAD?

I only found this question which interests me, but the answer is not consistent.

JDBC Statement/PreparedStatement per connection

The answer explain the relationship between recordset and statement, which is known to me.

Given that, you can not have multiple recordsets for statement

The answer says that you can have multiple recordsets for connection. But they are not mentioned any other sources.


I’m asking if it’s possible to loop over the first recordset, then using the same connection (used to generate first recordset) to open another recordset use it looping in iteration. And where is the documentation that define this behavior?


The situation that interests me is like this, the statement perform tasks simultaneously ins

Connection con = Factory.getDBConn (user, pss, endpoint, etc);
Statement stmt = con.createStatement ();
ResultSet rs = stmt.executeQuery ("SELECT TEXT FROM dba");

while (rs.next ()) {
 rs.getInt (....
 rs.getInt (....
 rs.getInt (....
 rs.getInt (....

 Statement stmt2 con.createStatement = ();
 ResultSet rs2 = stmt2.executeQuery ("iSelect ......");
 while (rs2.next ()) {
 ....
 rs2.close ();
 stm2.close ();

 Statement stmt3 con.createStatement = ();
 ResultSet rs3 = stmt3.executeQuery ("Insert Into table xxx ......");
 ....
 rs3.close ();
 stm3.close ();
}

To clarify a bit more: with the execution of update in stmt3, you could obtain an error like this:

java.sql.SQLException: There is an open result set on the current connection, which must be closed prior to executing a query.

So you can’t mix SQL in the same connection.

  • 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-10T01:36:24+00:00Added an answer on June 10, 2026 at 1:36 am

    If I understand correctly, you need to work with two (or more) resultsets simmultaneously within a single method.

    It is possible, and it works well. But you have to remember a few things:

    • Everything you do on each recordset is handled by a single Connection, unless you declare new connections for each Statement (and ResultSet)
    • If you need to do a multithreaded process, I suggest you to create a Connection for each thread (or use a connection pool); if you use a single connection in a multithreaded process, your program will hang or crash, since every SQL statement goes through a single connection, and every new statement has to wait until the previous one has finnished.

    Besides that, your question needs some clarification. What do you really need to do?

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

Sidebar

Related Questions

Brief question What command can I use to make my DataSet refresh it's connection
I have a question that can I use AS400ConnectionPool in Spring if then pls
HTML Javascript question to get the selected value of a input-select I can use
Have a rather simple question. Does anyone knows if i can use jparallax both
I'd like to use the html5 widget + it's api (http://developers.soundcloud.com/docs/html5-widget) My question: can
Well, question is in title. Is it possible at all? I can use css
I asked a question earlier about why left joins in Linq can't use defined
My question is, why I can not use hide() & show() to hide/show table
I ask a similar question here and Darin Dimitrov answer that we can't use
This question may be an absolute crap. Can i use the flex 4 sdk

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.