Isuru,
By allowing autocommit = true, your giving control of your JDBC logic
completely to database engine.
This will be problematic when you want to perform a rollback resulted by
multiple SQL statements.
For example:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
with autocommit=true
insertOrder()
//order saved to database
insertPayment()
//payment save to database
Here no way of rollbacking Order if payment is not successful.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
with autocommit=false
beginTxn {
insertOrder()
insertPayment()
} finally{
commitTxn()
} error {
rollback()
}
rollback operation can remove both payment and order records as they are
part of a single txn.
On Mon, Nov 23, 2015 at 4:03 PM, Isuru Perera <[email protected]> wrote:
> Hi,
>
> When we write JDBC code, is it okay if we depend on auto commit in the
> connection we get from the DataSource?
>
> The JDBC Reporter for Metrics [1] depends on auto commit "true" value set
> in the DataSource configuration. The JDBC reporter doesn't have any complex
> transactions and I thought it should be okay to depend on auto commit.
>
> WDYT?
>
> Thanks!
>
> Best Regards,
>
> [1]
> https://github.com/wso2/carbon-metrics/blob/v1.1.1/components/org.wso2.carbon.metrics.jdbc.reporter/src/main/java/org/wso2/carbon/metrics/reporter/JDBCReporter.java#L233-L258
>
> --
> Isuru Perera
> Associate Technical Lead | WSO2, Inc. | http://wso2.com/
> Lean . Enterprise . Middleware
>
> about.me/chrishantha
> Contact: +IsuruPereraWSO2 <https://www.google.com/+IsuruPereraWSO2/about>
>
--
/sumedha
m: +94 773017743
b : bit.ly/sumedha
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev