This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Learn Java with Math: Using Fun Projects and Games and have Ron Dai on-line!
See this thread for details.
Win a copy of Learn Java with Math: Using Fun Projects and Games this week in the Beginning Java forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Logging uncommitted transactions

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
I want to log information about all uncommitted transactions before calling rollback. or during roll back.
Is there any way to do that?
In my code,I have
setAutocommit(false)
executeQuery()
con.close();
performRollback();

Now in performRollback()is there any way to know about uncommitted transaction?

Saira
 
author & internet detective
Posts: 39655
785
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saira,
You would have to keep track of the relevant information yourself.

Note that you cannot do a rollback after you close the connection.
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saira,
Transactions only apply to operations that manipulate the data in the database -- in other words when you do DELETE, INSERT or UPDATE operations. Since (in the code you posted) you are calling the "executeQuery()" method, I assume you are performing a query. Since a query does not manipulate data, the "rollback" is redundant -- or am I missing something?

Most databases do not offer a way to access details of non-committed transactions, but if they do, then it is usually a proprietary way. So if database independence is important to you, I don't think your task is achievable.

Good Luck,
Avi.
 
Saira Murty
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Avi, thanks for your reply. I have jsut posted a pseduo code. the meaning of executeQuery is performing some SQL update. and in con.close() I am releasing the connection and putting it back to pool.
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!