java - Ability to rollback changes when insert data using a server API -


i have following situation:

i have build client java application, used communicate mysql database directly. when inserting lot of data, used autocommit turned off. easy do, because had direct access connection. had chosen this, because enabled me rollback changes when went wrong during synchronization.

now, application evolving , thought better build server api communicates mysql database. so, @ moment, inserting data doing http requests. each request opens , closes new connection.

now, able rollback changes when 1 of requests goes wrong. assume can not work autocommit, because based on connection, , 1 different each request.

can tell me how done usually?

i have thought of following:

  • first call url sets autocommit false, , requests , check if 1 fails. go wrong if client inserting data @ same time.
  • sending data server 1 request, force me alter design drastically.

note: know code required when asking question, can not see how improve question. however, if needed, feel free request it.

every web request should run in it's own transaction.

send data belongs logical transaction in 1 request , call commit @ end of request processing.

spaning transactions accros multiple web requests bad idea. think crashing clients never commit. leave open transactions never close.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -