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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:47:43+00:00 2026-05-29T21:47:43+00:00

As part of a web app i am trying to build a registration process.

  • 0

As part of a web app i am trying to build a registration process. after validating the process there are three sql statments to be performed. If any should fail then they should all be rolled back. However If i purposefully write the 3rd sql to fail (use a table name that doesnt exist). I see exception being thrown but the 1st and 2nd swl statments are not rolled back.

Can someone advise me on how this should be done.

from my application-context.xml

    <bean id="transactionManager" 
      class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
      <property name="dataSource" ref="dataSource"/>
    </bean>

    <bean id="userDAO" class="com.doyleisgod.golf.database.JdbcUserDao">
      <property name="dataSource" ref="dataSource"></property>
    </bean>

    <bean id="registration" class="com.doyleisgod.golf.services.Registration"/>

    <tx:annotation-driven /> 

My registration service class

public class Registration implements IRegistration {
@Autowired JdbcUserDao userDAO;

@Override
@Transactional (rollbackFor = Exception.class)
public boolean registerUser(Object command) {
    return userDAO.registerUser(command);
}
}

my userDAO registration method

    public boolean registerUser(Object command)  {
    try {
        setUserCommand(command);
        sql = "INSERT INTO users (USERNAME,PASSWORD, ENABLED)VALUES ('"+username+"', '"+EncryptedPassword+"', TRUE);";
        getSimpleJdbcTemplate().update(sql);

        sql = "INSERT INTO user_roles (USERNAME,AUTHORITY)VALUES ('"+username+"', 'ROLE_USER');";
        getSimpleJdbcTemplate().update(sql);

        sql = "INSERT INTO users_details (USERNAME,FIRST_NAME, LAST_NAME, EMAIL_ADDRESS, HANDICAP)VALUES ('"+username+"', '"+firstname+"', '"+lastname+"', '"+email+"', '"+handicap+"');";
        getSimpleJdbcTemplate().update(sql);

    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
        return true;
}

Exampl of exception being thrown

    15-Feb-2012 21:13:48 org.springframework.jdbc.support.SQLErrorCodesFactory <init>
INFO: SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [INSERT INTO users_details (USERNAME,FIRST_NAME, LAST_NAME, EMAIL_ADDRESS, HANDICAP)VALUES ('d', 'd', 'd', 'd', '0');]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'golf.users_details' doesn't exist

Can someone tell me what i have missed. Why when the 3rd sql statment fails do the other 2 transactions not get rolled back?

  • 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-29T21:47:44+00:00Added an answer on May 29, 2026 at 9:47 pm

    Because you are catching the exception in your DAO, it is not thrown to the TransactionManager.

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

Sidebar

Related Questions

I'm trying to build a visual web part for SharePoint 2010 which should connect
I have a python daemon running as a part of my web app/ How
Part of my app caches web pages for offline viewing. To do that, I
I am using spring web mvc for my app's UI part.. By using following
We have an Android app and a Web Service. We want to download part
I'm trying to get MSBuild 2010 to publish a web app to a specific
I'm trying to build small web-system (url shortcutting) using nonsql Cassandra DB, the problem
I am trying to migrate a simple WinForms app to a ASP.Net web app.
I am trying to create a web app that is querying my oracle database
I am trying to find a good media sharing web app. Something that will

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.