Hello I am doing employee information using JSP and msaccess. I wnat to use transaction here I am uploading employee photo and data also if any one of the fails then transaction should be aborted. I am saving data into MSACCESS but not storing photo in database, I am just saving that photo into a folder which I made on server. How should I proceed??? Pls all answers will be appreciated Rakesh
Your first problem is the use of Access (it's not very good) and the second more important issue is that you'll be trying to maintain a Transaction across two different operations, one which doesn't support transactions. You may be better off organising your code so that you do as much pre-processing and validation as possible before doing either operation. Then you have two directions to go... In the first, you write the file, if that succeeds you perform the database operation and commit it. If the database operation fails, you go back and delete the file. There is the possibility you'll fail in the database and be unable to delete the file, but hopefully that isn't a huge problem having a few unattached files. In the second, you perform the database operation but do not commit. Then you write the file. If the file operation succeeds, you commit the database operation. The direction you go down depend on how large the files are and if you are able to hold transaction open long enough. Hope this gets you started, Dave.
Another (design/architecture/maintenance) problem is putting application logic inside the JSPs. Better separate out the database access to a Javabean which handles all database logic. If you then decide to move to another solution you need only change that bean. MS Access is nice for rapid prototyping but unless your organisation has more than one or two people using the system it's underpowered. A way to prevent dead files on your filesystem if database operations fail is to have a batchjob running once a day or so that deletes all images that are no longer referenced from the database. That way it also gets a lot easier to delete a record, as the deletion of the associated image(s) will be handled automagically for you and you don't need to bother with it in the database routines.
Originally posted by Jeroen Wenting: Another (design/architecture/maintenance) problem is putting application logic inside the JSPs.
Agreed, a JSP is completely the wrong place to dump all this logic. The other problem with Access is that most people use the JDBC-ODBC bridge, and this is simply useless in a production environment. It isn't even thread-safe.