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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:05:49+00:00 2026-05-23T12:05:49+00:00

The Spring framework provides two means of programmatic transaction management: Using the TransactionTemplate .

  • 0

The Spring framework provides two means of programmatic transaction management:

  1. Using the TransactionTemplate.

  2. Using a PlatformTransactionManager implementation directly.

The above is described here: http://static.springsource.org/spring/docs/2.0.8/reference/transaction.html

The Spring site hasnot mentioned JdbcTemplate here. As per my understanding JdbcTemplate also manages the transaction internally and this is all done in programme too.

So what’s the basic difference between TransactionTemplate and JdbcTemplate?

  • 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-23T12:05:50+00:00Added an answer on May 23, 2026 at 12:05 pm

    JdbcTemplate is not a transaction manager. It’s merely a helper class for native JDBC operations:

    This is the central class in the JDBC core package. It simplifies the use of JDBC and helps to avoid common errors. It executes core JDBC workflow, leaving application code to provide SQL and extract results. This class executes SQL queries or updates, initiating iteration over ResultSets and catching JDBC exceptions and translating them to the generic, more informative exception hierarchy defined in the org.springframework.dao package.

    TransactionTemplate by the way is also not a transaction manager, it’s a

    Template class that simplifies programmatic transaction demarcation and transaction exception handling.

    The PlatformTransactionManager (and other subclasses of AbstractPlatformTransactionManager) is a transaction manager, as in it

    • determines if there is an existing transaction;
    • applies the appropriate propagation behavior;
    • suspends and resumes transactions if necessary;
    • checks the rollback-only flag on commit;
    • applies the appropriate modification on rollback (actual rollback or setting rollback-only);
    • triggers registered synchronization callbacks (if transaction synchronization is active).

    So this class is responsible for the actual transaction handling, as opposed to the TransactionTemplate, which is to be used if you instead of declarative transaction handling you want to implement it programmetically. (see this blog, though quite outdated, you will see the difference between declarative and manual)

    Quotes from Spring 3 Reference.

    Note: Throughout the Spring Framework you will find other *Template classes as well: HibernateTemplate, JmsTemplate etc. They all follow the same pattern: template classes which radically reduce the amount of code you need to write, because all the so-called boilerplate code will be handled by them. Example (from here):

    Without JdbcTemplate:

    private DataSource dataSource;
    
    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }
    
    public void insert(Customer customer){
    
        String sql = "INSERT INTO CUSTOMER " +
                "(CUST_ID, NAME, AGE) VALUES (?, ?, ?)";
        Connection conn = null;
    
        try {
            conn = dataSource.getConnection();
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setInt(1, customer.getCustId());
            ps.setString(2, customer.getName());
            ps.setInt(3, customer.getAge());
            ps.executeUpdate();
            ps.close();
    
        } catch (SQLException e) {
            throw new RuntimeException(e);
    
        } finally {
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException e) {}
            }
        }
    }
    

    And with JdbcTemplate:

    private DataSource dataSource;
    private JdbcTemplate jdbcTemplate;
    
    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }
    
    public void insert(Customer customer){
    
        String sql = "INSERT INTO CUSTOMER " +
            "(CUST_ID, NAME, AGE) VALUES (?, ?, ?)";
    
        jdbcTemplate = new JdbcTemplate(dataSource);
    
        jdbcTemplate.update(sql, new Object[] { customer.getCustId(),
            customer.getName(),customer.getAge()  
        });
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have started using Spring framework in my project. After becoming acquainted with the
Our application is developed using Spring framework. Is it good practice to check null
We are developing a web application using Spring framework and Hibernate ORM. As far
I have a j2ee application running on spring framework. I am implementing a transaction
Spring provides the FactoryBean interface to allow non-trivial initialisation of beans. The framework provides
I'm using Spring framework and I don't know how to do this simple thing:
I am using Spring framework mvc 3 + spring security 3. I would like
I have used spring framework 3 for my application. Everything is ok while developed
My project is based on spring framework 2.5.4. And I try to add aspects
I'm pretty new to the Spring Framework, I've been playing around with it and

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.