Announcement Announcement Module
Collapse
No announcement yet.
How to write transaction in Java Application Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to write transaction in Java Application

    Hi

    I have java appllication in which I am passing a Oracle DataSource from Business class to DAO layer. In DAO layer, there are multiple stored procedures from which I insert data in DB using spring framework.

    Now the problem I face here is when I run the application, inserted data is not reflected in Database i.e. application is not comitting the changes. For this I dont know how to set autocomit flag to true in spring framework.

    Also can you tell me how I can write a transaction in Java standalone application using spring framework. I need to rollback the changes if any of the execution of procedure fails.

    Thanks in advance!!

  • #2
    see transaction documentation in spring, i will see that using AOP is as simple as you can think.

    Comment


    • #3
      transactions/jdbc/spring

      Check out
      http://www.springframework.org/docs/...ansaction.html

      I use jdbc with declarative transactions - it works nicely.

      Comment


      • #4
        DataSource in Business layer?

        Hi sachinb4u,

        Originally posted by sachinb4u View Post
        I have java appllication in which I am passing a Oracle DataSource from Business class to DAO layer. In DAO layer...
        I'm not trying to be nosey; maybe this is a legacy application, but it seems odd for the business layer to be DataSource-aware. Are you refactoring an existing application to use Spring, or are you writing this from scratch? If you are writing from scratch, it would make more sense to define your DataSource in a Spring applicationContext file, and to have that DataSource injected into the DAOs. Check out the Spring Reference for more information, or re-post with additional questions.

        -Arthur Loder

        Comment

        Working...
        X