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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:32:19+00:00 2026-05-31T08:32:19+00:00

I am using Spring with JDBC and found that it is autocommit. How can

  • 0

I am using Spring with JDBC and found that it is autocommit.

How can I config to turn it off in spring-servlet.xml?

This is my current configuration:

<bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
    p:driverClassName="${jdbc.driverClassName}"
    p:url="${jdbc.databaseurl}" p:username="${jdbc.username}"
    p:password="${jdbc.password}" />

<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource"/>
</bean>
  • 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-31T08:32:21+00:00Added an answer on May 31, 2026 at 8:32 am

    It seems that my configuration missed this line:

    <tx:annotation-driven transaction-manager="txManager"/>
    

    Then, in my service classes, I use @Transactional annotation. For example

    @Service
    class CompanyServiceImpl implements CompanyService{
        @Autowired
        private CompanyDAO companyDAO;
    
        @Transactional
        public void addCompany(Company company) {
                companyDAO.addCompany(company); // in here, there is JDBC sql insert
                companyDAO.addCompany_fail(company); // just for test
        }
    }
    

    If there is a exception happening in the addCompany_fail(), the first addCompany() one will also be rollbacked.

    I followed this document to understand idea how transaction controlled in Spring.
    http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/transaction.html

    I followed this document to understand how to code with JDBC in Spring.
    http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/jdbc.html

    I also read this (Free) http://www.infoq.com/news/2009/04/java-transaction-models-strategy. It is really good one. And I feel the same with the writer that most people do not understand (or care) about transaction.

    PS:
    Seem that many people misunderstand that using such Hibernate/Spring framework is only for avoid complexity of JDBC and Transaction Control. Many people think like “JDBC and Transaction are so complex, just use Hibernate and forget about those two”. Many examples on the internet about Spring+Hibernate or Spring+JDBC seemingly not care about transaction at all. I feel that this is a bad joke. Transaction is too serious for just letting something handle it without truly understanding.

    Hibernate and Spring is so powerful and so complex. Then, as someone said, “Great power comes with responsibilities”.

    UPDATE: 2013-08-17: There are good example about transaction here http://www.byteslounge.com/tutorials/spring-transaction-propagation-tutorial. However, this is not explain that if you want to use REQUIRES_NEW, why you need to create another class (otherwise you will get this problem Spring Transaction propagation REQUIRED, REQUIRES_NEW , which it seems REQUIRES_NEW does not really create a new transaction)

    Update: 2018-01-01: I have created a full example with Spring Boot 1.5.8.RELEASE here https://www.surasint.com/spring-boot-database-transaction-jdbi/
    and some basic experiment examples here https://www.surasint.com/spring-boot-connection-transaction/

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

Sidebar

Related Questions

I found an issue connecting my web application using JDBC or Spring to a
i'm reading liferay source code and found out that 2 xml files using same
I'm using Spring's support for JDBC. I'd like to use JdbcTemplate (or SimpleJdbcTemplate) to
We are using Spring SimpleJdbcCall to call stored procedures in Oracle that return cursors.
I'm using xapool (org.enhydra.jdbc.pool.StandardXAPoolDataSource) with Spring and JPA and I'm getting connection timed out
I'm using DBCP data source (with default configuration) in Spring configuration to manage my
I'm using Spring JDBC. Is a simple way to get last inserted ID using
I am using Spring JdbcTemplate/SimpleJdbcTemplate in combination with an Oracle datasource (oracle.jdbc.pool.OracleDataSource) via JNDI
I'm having trouble retrieving data from my database using Spring Jdbc. Here's my issue:
I've installed postgresql 9.1 for Windows but I can't connect to it using JDBC.

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.