Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

How to handle Transaction with JDBC which could not be rollbacked?

 
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends..

i use Swing + MySQL v5.0.81 +JDBC
is it possible the transaction could not be rollbacked?..
so what i have to do to handle it?..
do i have to rollback it manually?..
but i guess it is a hard work to rollback it manually..
is there any solution?

what kind of query which cause the query could not be rollbacked?..

Thanks in advance
 
Bartender
Posts: 4107
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

what kind of query which cause the query could not be rollbacked?..



I haven't heard any query like that so far .....
 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Vijitha

Thanks for your reply..
what do you mean that all of transactions could be rollbacked?..

if there suddenly the electricity is turned off, does the transactions could be rollbacked also?..
i have just faced the problem, when the electricity is turned off suddenly (caused by the electricity provider).. and the table is crashed..
and the the transaction could not be rollbacked...

Does MySQL especially InnoDB storage engine can handle this case?..

Thanks in advance..



 
Vijitha Kumara
Bartender
Posts: 4107
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

when the electricity is turned off suddenly (caused by the electricity provider).. and the table is crashed..
and the the transaction could not be rollbacked...


Transactions are done within an active connection. Once you lost the connection to the DB server you are unable to perform the next operation(s).
 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about if the transaction is still in process..
example the tasks in the transaction like this, and the electricity turned off suddenly, does the transaction could be rollbacked?..




does in that case the transaction would be rollbacked automatically by MySQL?..

Thanks in advance
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you lose a connection you lose all associated resources, transaction included, which is the same as a rollback. If there has been no comit then the database will time it out (assuming you are using a MySQL db engine that supports transactions in the first place).

 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic