• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Transaction in JSP

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
These are the worst of times and these are the best of times. And this is the best tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic