java - Transaction Control over a Connection Pool -


i have multithreaded application wherein parsing file , inserting database - have db connection pool writing database - need add transaction control on parse/write entire operation i.e. in case of error during parse/db-insert operation, want rollback entire operation wherein partial db writes need rolled back- there way this?

you'll need take connection out of pool, start database transaction on it, , keep out of pool duration of transaction. you'll return pool once finish (commit or rollback) transaction.

this means cannot run more transactions in parallel have connections in pool. if cannot accept limitation, you'll have devise own workaround doesn't rely on database transactions (e.g. using "stage" table accepts data unique identifier, moving main storage @ once, plus task delete stale data).

i recommend reading on spring's transaction manager inspiration.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -