• 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Prepared statement, execute batch, commit, rollback  RSS feed

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody!

Yes I know that this subject has been discussed before but I cannot find something helpful..


In a try block I have the following things..
I have prepared statements to INSERT data into a database. I put the statements in a batch.

Then I call executeBatch() and conn.commit.

In the catch block I call the rollback()..


The problem is that I do not know if the rollback works..



Is there anywhere a complete example showing how rollback works with prepared statements in a batch?


As you can understand I am really newbie and this is why I am not describing everything in a proper way..

Thanks for the effort!
 
Dimitrios Chatzidimitriou
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No matter how I try I cannot make it work..

Example code..




Can anyone tell me where rollback should be placed?


Thanks!
 
Ranch Hand
Posts: 108
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The problem is that I do not know if the rollback works..


You can use debug statements or logger to track the inserted data.
or if you are using Eclipse IDE, you can mark a breakpoint within

You may use My SQL Workbench to check if all the rows were inserted in the database.
If you want to validate if the rollback occurs, you can insert invalid data.

Is there anywhere a complete example showing how rollback works with prepared statements in a batch?


Its not the combination of batch and rollback that matters here just know the individual concepts. You can find plenty of examples. example1 and example2 will get you started. Looks like execute batch is working fine, if you do not find debug statements in your console
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!