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 6029765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:56:07+00:00 2026-05-23T04:56:07+00:00

Is recommended to create just one Statement object and execute multiple executeUpdate() on it?

  • 0

Is recommended to create just one Statement object and execute multiple executeUpdate() on it?

// Vantages/drawbacks of this solution?
conn.setAutocommit(false);

Statement stmt = conn.createStatement();
stmt.executeUpdate('[ANY_INSERT_SQL]');
stmt.executeUpdate('[ANY_INSERT_SQL]');
stmt.executeUpdate('[ANY_INSERT_SQL]');

conn.commit();

Or is better one Statement object for each executeUpdate:

// Vantages/drawbacks of this solution?
conn.setAutocommit(false);

Statement stmt1 = conn.createStatement();
stmt1.executeUpdate('[ANY_INSERT_SQL]');
Statement stmt2 = conn.createStatement();
stmt2.executeUpdate('[ANY_INSERT_SQL]');
Statement stmt3 = conn.createStatement();
stmt3.executeUpdate('[ANY_INSERT_SQL]');

conn.commit();

Thanks in advance.

PS: I know PreparedStatement class and I use it often, but my doubt is about Statement usage.

  • 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-05-23T04:56:08+00:00Added an answer on May 23, 2026 at 4:56 am

    Based on the javadoc, A statement can have only one associated ResultSet object.

    The object used for executing a static
    SQL statement and returning the
    results it produces.

    By default, only one ResultSet object
    per Statement object can be open at
    the same time. Therefore, if the
    reading of one ResultSet object is
    interleaved with the reading of
    another, each must have been generated
    by different Statement objects. All
    execution methods in the Statement
    interface implicitly close a
    statment’s current ResultSet object if
    an open one exists.

    http://download.oracle.com/javase/1.4.2/docs/api/java/sql/Statement.html

    If you need to process multiple results sets at the same time, perhaps, more statements make sense.

    Probably more often than not, you only need to use one.

    Performance-wise, probably better as it keeps fewer resources active.

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

Sidebar

Related Questions

I'm just wondering which one is better, or more recommended for processing form data.
What's the recommended source control system for a very small team (one developer)? Price
I'd like to create/update a sub-object within an admin edit dialog. I have a
I have an object in C# like this: private ClassWidget { public int ID;
If this is recommended ? Can I ask some git command examples about how
In the solution I have worked out to this question => General type conversion
I recently read through Code Complete, and it recommends that I create a project
Can anyone recommend a program to create user manuals with? Not a markup language
Recommended by the ASP.NET team to use cache instead of session, we stopped using
Any recommended practices for cleaning up header spaghetti which is causing extremely slow compilation

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.