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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:03:47+00:00 2026-06-09T21:03:47+00:00

Suppose that I have an application using ibatis 2 and spring 1. I have

  • 0

Suppose that I have an application using ibatis 2 and spring 1. I have an external class that calls the dao method. What will happen if the following code is run:

// external class

public void doSomething() {
    try {
        daoLayer.startTransaction();
        daoLayer.firstOperation();
        daoLayer.secondOperation();
    } finally {
        daoLayer.endTransaction();
    }
}

// dao layer which extends from org.springframework.orm.ibatis.support.SqlMapClientDaoSupport.SqlMapClientDaoSupport

public void startTransaction() { sqlMap.startTransaction(); }
public void firstOperation() { sqlMap.update("someQuery"); }
public void secondOperation() { sqlMap.update("someOtherQuery"); }
public void endTransaction() { sqlMap.endTransaction(); }
  1. Will this code cause database connections to be leaked?
  2. Will end transaction be run on the same transaction/db connection which executed the startTransaction, firstOperation, and secondOperation methods? Or might dbcp/ibatis pick a different connection out of the pool?
  3. What could I do to test and make sure that the same connection is used for all the operations and that the transaction is working correctly?
  4. (Added via Edit) – Would anything change if I moved all my logic into a single method in the dao? Would that be more transaction safe?
  • 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-09T21:03:49+00:00Added an answer on June 9, 2026 at 9:03 pm

    Will this code cause database connections to be leaked?

    No. but to commit data, you need to include sqlMap.commitTransaction() after daoLayer.secondOperation().

    Will end transaction be run on the same transaction/db connection which executed the startTransaction, firstOperation, and secondOperation methods? Or might dbcp/ibatis pick a different connection out of the pool?

    Yes .. if are opening a transaction you need to close it otherwise database server doesn’t close the transaction and it will be expired as per server settings.

    What could I do to test and make sure that the same connection is used for all the operations and that the transaction is working correctly?

    In java: check logs for connection id. You can also check database server for assigned connection id.

    Would anything change if I moved all my logic into a single method in the dao? Would that be more transaction safe?

    No matter, if you have a single or multiple DAO operations in a single transaction.

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

Sidebar

Related Questions

Suppose I have an application that will draw 20 little UIImageViews on the screen.
Suppose that you have a big Data Entry Web Application Like Microsoft CRM ,
Suppose I have a GUI-only application that runs on Windows and I'd like to
Suppose that we have following tables create table Employee( 2 EMPNO NUMBER(3), 3 ENAME
I have an application that's suppose to be realized in plugin pattern. Plugins are
I'm trying to design application that will have UI with database in the backend.
I have a wxPython application ( http://www.OpenSTV.org ) that counts ballots using methods that
I have an application using discovery that may be deployed locally on the same
This is a general question. Using an example below, suppose that I have a
I have an application that is supposed to aid my project in terms of

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.