java - JDBC Autocommit to false in application level -


when of best programming approaches recommend set jdbc auto commit false, rational behind jdbc api design set default value true?

what rational behind jdbc api design set default value true?

you take transactions under control setting connection.setautocommit(false) when dealing multiple insert/update sql queries (handling through jdbc) within/across database tables atomic operation, needed medium/complex sized applications.

now, if transactions have handled explicitly (i.e., suggested if connection.setautocommit(false) default), developers should careful single insert/update sql query (handling through jdbc) ensuring commit() , rollback() have been handled properly, otherwise connection hanging , quite hard debug.

if auto-commit mode has been disabled, method commit must called explicitly in order commit changes; otherwise, database changes not saved.

you can here

following approach i.e., calling commit explicitly each , every transaction unnecessary , if ignore once, more harm good.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -