• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

AS400 rolledback

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem when I'm saving records in a database in AS400. I put transactionz supported, requiered, not supported, etc) to the EJB, that is using the method who is writing to the database. Every thing its ok, but after 10 mins or more or sundently send the rolled back, and delete all records saved. If I do not use transacactions (supported, requeried, etc) I receive rolled back instantly, and finish with error. With transaccions I do not receive nothing and I don't know how to find the error, because the rolledback happens after time.

I'm using whebsphere 5.1 and the conection is with datasoruces, maybe I need something else in datasources.

Does anyone can help me, because I have a lot of time with this problem. Any commentary It will be useful. Thanks for your help.
 
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My guess would be that you disabled autocommit and then never issued a commit -- the result being that you build up transactions in the log/journal until it reaches a critical threshold. When the threshold is reached, an exception is thrown internally forcing the connection to close and rollback.
 
Rolando Ochoa
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your answer David you were very helpful. I put commit after save all records, and it work fine, there is not rollbak and the records are ok. But I still have a problem. I put null in a Data (after 9000 records) and an error exists when I try to save records, I just wanted to see if rollback happens but it dosen't work, the rollback not exist. The data null error is before commit, so the commit is not executed. Maybe it will happens after long time, maybe 3 hrs, or more or never happens.

How can I force the rollback?, or do exist any way to run it manually and immediately? any suggestion could help me.

I did my test of transactions with supports and not supports

thanks in advance...
 
David Hibbs
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that's what try/catch/finally is for. =)

//Declare connection
Connection conn = null;
try
{
// get connection
// process data
// commit changes
}
catch(Exception e)
{
// handle exception;
// if conn!=null roll back
// (and anything else you want to do)
}
finally
{
// if conn!=null close it
}

Every step above is necessary or you'll have issues. You'll either commit something you don't want, roll back something you do, or leak connections.
That's all bad.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic