Coordinated save in database and disk in java

In my task I need to save file on disk and update info about in database. Exception can happen when saving file and when updating info in database. Do exist some ready open source solutions for it or it need write from scratch? Thanks.

Answers


There's XADisk which provides transactional access to file systems. From their web site:

XADisk (pronounced 'x-a-disk') enables transactional access to existing file systems by providing APIs to perform file/directory operations. With simple steps, it can be deployed over any JVM and can then start serving all kinds of Java/JavaEE application running anywhere.


In Java, enterprise transactions management is ruled by the JTA spec wich is used in Java EE.

JTA allows to create several TransactionManager with differents implementations (one for database, one for file) and make them work together to define a cross-transaction I think this could be a way for you to do what you want

Outside of a container, there are possibility to integrate JTA. You should have a look at Spring or JBoss implementations

Look at this blog post for more information about Spring and transactions usage


The file system isn't directly supported by Java EE, but you could implement/ search for a resource adapter for the file system.

http://docs.oracle.com/javaee/6/tutorial/doc/gipgl.html

http://docs.oracle.com/javaee/6/tutorial/doc/giqjk.html


Need Your Help

iOS 7 UIPickerView not showing what it should, iOS 6 UIPickerView does

ios objective-c uipickerview

I have this method for making a font picker and an image for fonts that aren't currently available. For some reason, it shows up perfectly fine on iOS 6, but the image doesn't show up at all on iOS...

Access a variable on a controller on two seperate visualforce pages

salesforce visualforce apex salesforce-service-cloud

I have two visual force pages that use the same controller. There a few fields which I set on the first visual page which I would like to access on the second visualforce page. I was wondering how I