• 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

Data preservation

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an application that takes data from .xl spreadheet, converst it to a string and loads it to database via CICs. There were no problems until recently, when two users managed to load two spreadsheets at the same time and data in the load from first spreadheet included some data from the second one. What will be the best approach to address this issue?

Thank you,
Irene
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Need more information about the code and how you actually do the reads and writes.

On the outset, it looks like a synchronization issue. Depending on your current implementation, the solution could be very simple to somewhat complicated. But definitely do-able.
 
Irene Loos
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The controller passes uploaded file to service that will extract data

try{
jxl.Workbook workbook = jxl.Workbook.getWorkbook(new ByteArrayInputStream(spreadsheet.getStream().toByteArray()));

for (int sheet = 0; sheet < workbook.getNumberOfSheets(); sheet++){
Sheet s = workbook.getSheet(sheet);
loadSpreadsheet(s, messageIds, linkType);
}
}catch(ValidationException ex){// catch exceptions thrown from load
throw(ex);
}catch(Exception ex){
//error handling
}catch(OutOfMemoryError err){
//error handling
}


The method loadSpreadsheet() will set values from spreadsheet to serializable object. This object will be used to pass data to CICS. I think it was corrupted before it went to CICS.
[ November 29, 2007: Message edited by: Irene Loos ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where does this run ... desktop? Web server? Other?

Any chance two user threads are calling loadSpreadSheet() at the same time and writing over each other's values in a member variable?
 
Irene Loos
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It runs on WebServer (Webshere) and yes, I suspect that two users run at the same time. My question is what better to use to prevent this. Will serialization help? Or should I use something else?
 
Murali Nanchala
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see two places where there is a potential for trouble. First, when you are reading in from the Spreadsheet. Second, when you are writing to the serialized object.

Not sure what your access modifiers are on the two methods, but yes, two users can potentially corrupt the read and/or writes.

What kind of access does the method (you posted) in the service allow?

Since it is in turn calling the loadSpreadSheet() method, restricting access to this method should suffice your need. But if you want a less obtrusive way, just synchronize the serialized object and go from there.
 
Irene Loos
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The methods have private access. Thank you very much. I will try to synchronize.

Irene
 
reply
    Bookmark Topic Watch Topic
  • New Topic