• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Doubt in Transaction

 
Greenhorn
Posts: 18
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


In the above Code, Consider con is an active Connection and the code is wrapped with proper Exception Handling.. I want to know whether the records will be commited or not...
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.
 
Sathish Kumar Govindan
Greenhorn
Posts: 18
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,
<pre>

As You said it was not working.. The Records have been inserted after executing the code....
I am Using Oracle thin driver....I think whenever we don't give commit or rollback and closing the connection smoothly,
the cached transactions are getting commited even though we set AutoCommit as false...

</pre>
with thanks,
Sathish Kumar.G

 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What cached transactions?

If your insert statements are successful, and you can query the database for these two records after your program has completed then one of two things could be true:
  • the code below is not the code you are running.
  • your driver is buggy


  •  
    Ranch Hand
    Posts: 257
    Hibernate Oracle Spring
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hey Satish,

    I tried the following three code sections. In the first one when I used conn.commit(), the changes got committed. I verified that by firing the select query in database from pl/sql developer. In case of second and third code sections changes were not persistent and were not committed.

    First -




    Second




    Third




     
    I have always wanted to have a neighbor just like you - Fred Rogers. Tiny ad:
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic