You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Brian Bonner <br...@paraware.com> on 2005/08/15 20:55:56 UTC

Threading (again)

Hi Guys,

I had a request from someone to allow them to write forms directly to an 
Excel spreadsheet. This user is not a developer, but does do web design 
and is fairly fluent with HTML, xHTML.  Anyway.

I have written a tag library to allow read/write access to/from Excel 
spreadsheets using POI.  It works well, and I know that POI is not 
threadsafe.

I could synchronize access to calls made by the tags to POI.  But I'm 
also concerned about a user opening up the file and locking up the app.

Any suggestions?

-- 
Brian



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: Threading (again)

Posted by ac...@apache.org.
This is the same problem you'd have with any other type of file (nothing 
really excel/poi particular here).  XLS is not a good database or data 
transmit format its a horribly inefficient and wasteful format.  I 
suggest using MySQL or Postgresql.  They're free and easy to 
administrate (esp mysql).  if you have to write to blobs use postgresql 
as Mysql's blobs are not efficiently implemented.

Brian Bonner wrote:
> Thanks Mark.  using a semaphore or other sort of lock will probably work 
> as well.
> I think the real solution is getting these folks to use a relational 
> database.  It's a very small business with no IT staff.
> 
> Brian
> 
> 
> 
> Anthony Andrews wrote:
> 
>> Hello Brian
>>
>> Ages ago, we wrote an application - using Visual Basic
>> would you believe - that created, updated and
>> generally messed around with .doc files. The only
>> practical way we could find to overcome the same type
>> of problem was to write our own application to control
>> access to the file(s).
>>
>> Put simply, when a user accessed a file, a record was
>> written into a log. If anyone else tried to access the
>> file, the first thing we did was to consult the log.
>> If the file had not been checked out, they were
>> allowed access to it, but if the file had been checked
>> out they were simply prevented from loading that file.
>> Then, as soon as a person finished with a file, it
>> would be rendered accessible again by being checked in
>> so to speak - removed from the log.
>>
>> It worked but did impose some overhead and of course
>> that overhead became more of a problem as the volumne
>> of files grew and more and more users gained access to
>> the system.
>>
>> Do not know if that helps? It may be possible to
>> implement something similar using a shared object that
>> maintains an internal ArrayList of file names and has
>> synchronised methods to check and update that
>> ArrayList.
>>
>> Yours
>>
>> Mark B
>>
>>
>>
>> --- Brian Bonner <br...@paraware.com> wrote:
>>
>>  
>>
>>> It seems like I need to synchronize access to the
>>> tags that perform these updates.  Here's my rationale.  My tags read
>>> the workbook to figure out the row count and perform an insert on a
>>> cell of a specific row and then save it back to the file.  If two
>>> requests come into this JSP at the same time, they'll both have the same
>>> initial picture of the file (assuming it will even be read and won't 
>>> throw
>>> a lock or FileNotFoundException) and when they update, the
>>> last update will win.
>>>
>>> But still this synchronization solution doesn't seem
>>> to help at the file level.  Additional thoughts?
>>>
>>> Brian
>>>
>>>
>>>
>>> Brian Bonner wrote:
>>>
>>>   
>>>
>>>> Hi Guys,
>>>>
>>>> I had a request from someone to allow them to
>>>>     
>>>
>>> write forms directly to   
>>>
>>>> an Excel spreadsheet. This user is not a
>>>>     
>>>
>>> developer, but does do web   
>>>
>>>> design and is fairly fluent with HTML, xHTML.     
>>>
>>> Anyway.
>>>   
>>>
>>>> I have written a tag library to allow read/write
>>>>     
>>>
>>> access to/from Excel   
>>>
>>>> spreadsheets using POI.  It works well, and I know
>>>>     
>>>
>>> that POI is not   
>>>
>>>> threadsafe.
>>>>
>>>> I could synchronize access to calls made by the
>>>>     
>>>
>>> tags to POI.  But I'm   
>>>
>>>> also concerned about a user opening up the file
>>>>     
>>>
>>> and locking up the app.
>>>   
>>>
>>>> Any suggestions?
>>>>
>>>>     
>>>
>>>
>>>   
>>
>> ---------------------------------------------------------------------
>>  
>>
>>> To unsubscribe, e-mail:
>>> poi-user-unsubscribe@jakarta.apache.org
>>> Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
>>> The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
>>>
>>>
>>>   
>>
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam?  Yahoo! Mail has the best spam protection around 
>> http://mail.yahoo.com
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
>> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>>
>>  
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
> 
> 


-- 
Andrew C. Oliver
SuperLink Software, Inc.

Java to Excel using POI
http://www.superlinksoftware.com/services/poi
Commercial support including features added/implemented, bugs fixed.


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: Threading (again)

Posted by Brian Bonner <br...@paraware.com>.
Thanks Mark.  using a semaphore or other sort of lock will probably work 
as well.
I think the real solution is getting these folks to use a relational 
database.  It's a very small business with no IT staff.

Brian



Anthony Andrews wrote:

>Hello Brian
>
>Ages ago, we wrote an application - using Visual Basic
>would you believe - that created, updated and
>generally messed around with .doc files. The only
>practical way we could find to overcome the same type
>of problem was to write our own application to control
>access to the file(s).
>
>Put simply, when a user accessed a file, a record was
>written into a log. If anyone else tried to access the
>file, the first thing we did was to consult the log.
>If the file had not been checked out, they were
>allowed access to it, but if the file had been checked
>out they were simply prevented from loading that file.
>Then, as soon as a person finished with a file, it
>would be rendered accessible again by being checked in
>so to speak - removed from the log.
>
>It worked but did impose some overhead and of course
>that overhead became more of a problem as the volumne
>of files grew and more and more users gained access to
>the system.
>
>Do not know if that helps? It may be possible to
>implement something similar using a shared object that
>maintains an internal ArrayList of file names and has
>synchronised methods to check and update that
>ArrayList.
>
>Yours
>
>Mark B
>
>
>
>--- Brian Bonner <br...@paraware.com> wrote:
>
>  
>
>>It seems like I need to synchronize access to the
>>tags that perform 
>>these updates.  Here's my rationale.  My tags read
>>the workbook to 
>>figure out the row count and perform an insert on a
>>cell of a specific 
>>row and then save it back to the file.  If two
>>requests come into this 
>>JSP at the same time, they'll both have the same
>>initial picture of the 
>>file (assuming it will even be read and won't throw
>>a lock or 
>>FileNotFoundException) and when they update, the
>>last update will win.
>>
>>But still this synchronization solution doesn't seem
>>to help at the file 
>>level.  Additional thoughts?
>>
>>Brian
>>
>>
>>
>>Brian Bonner wrote:
>>
>>    
>>
>>>Hi Guys,
>>>
>>>I had a request from someone to allow them to
>>>      
>>>
>>write forms directly to 
>>    
>>
>>>an Excel spreadsheet. This user is not a
>>>      
>>>
>>developer, but does do web 
>>    
>>
>>>design and is fairly fluent with HTML, xHTML. 
>>>      
>>>
>>Anyway.
>>    
>>
>>>I have written a tag library to allow read/write
>>>      
>>>
>>access to/from Excel 
>>    
>>
>>>spreadsheets using POI.  It works well, and I know
>>>      
>>>
>>that POI is not 
>>    
>>
>>>threadsafe.
>>>
>>>I could synchronize access to calls made by the
>>>      
>>>
>>tags to POI.  But I'm 
>>    
>>
>>>also concerned about a user opening up the file
>>>      
>>>
>>and locking up the app.
>>    
>>
>>>Any suggestions?
>>>
>>>      
>>>
>>
>>    
>>
>---------------------------------------------------------------------
>  
>
>>To unsubscribe, e-mail:
>>poi-user-unsubscribe@jakarta.apache.org
>>Mailing List:    
>>http://jakarta.apache.org/site/mail2.html#poi
>>The Apache Jakarta Poi Project: 
>>http://jakarta.apache.org/poi/
>>
>>
>>    
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
>The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: Threading (again)

Posted by Anthony Andrews <py...@yahoo.com>.
Hello Brian

Ages ago, we wrote an application - using Visual Basic
would you believe - that created, updated and
generally messed around with .doc files. The only
practical way we could find to overcome the same type
of problem was to write our own application to control
access to the file(s).

Put simply, when a user accessed a file, a record was
written into a log. If anyone else tried to access the
file, the first thing we did was to consult the log.
If the file had not been checked out, they were
allowed access to it, but if the file had been checked
out they were simply prevented from loading that file.
Then, as soon as a person finished with a file, it
would be rendered accessible again by being checked in
so to speak - removed from the log.

It worked but did impose some overhead and of course
that overhead became more of a problem as the volumne
of files grew and more and more users gained access to
the system.

Do not know if that helps? It may be possible to
implement something similar using a shared object that
maintains an internal ArrayList of file names and has
synchronised methods to check and update that
ArrayList.

Yours

Mark B



--- Brian Bonner <br...@paraware.com> wrote:

> It seems like I need to synchronize access to the
> tags that perform 
> these updates.  Here's my rationale.  My tags read
> the workbook to 
> figure out the row count and perform an insert on a
> cell of a specific 
> row and then save it back to the file.  If two
> requests come into this 
> JSP at the same time, they'll both have the same
> initial picture of the 
> file (assuming it will even be read and won't throw
> a lock or 
> FileNotFoundException) and when they update, the
> last update will win.
> 
> But still this synchronization solution doesn't seem
> to help at the file 
> level.  Additional thoughts?
> 
> Brian
> 
> 
> 
> Brian Bonner wrote:
> 
> > Hi Guys,
> >
> > I had a request from someone to allow them to
> write forms directly to 
> > an Excel spreadsheet. This user is not a
> developer, but does do web 
> > design and is fairly fluent with HTML, xHTML. 
> Anyway.
> >
> > I have written a tag library to allow read/write
> access to/from Excel 
> > spreadsheets using POI.  It works well, and I know
> that POI is not 
> > threadsafe.
> >
> > I could synchronize access to calls made by the
> tags to POI.  But I'm 
> > also concerned about a user opening up the file
> and locking up the app.
> >
> > Any suggestions?
> >
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> Mailing List:    
> http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project: 
> http://jakarta.apache.org/poi/
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: Threading (again)

Posted by Brian Bonner <br...@paraware.com>.
It seems like I need to synchronize access to the tags that perform 
these updates.  Here's my rationale.  My tags read the workbook to 
figure out the row count and perform an insert on a cell of a specific 
row and then save it back to the file.  If two requests come into this 
JSP at the same time, they'll both have the same initial picture of the 
file (assuming it will even be read and won't throw a lock or 
FileNotFoundException) and when they update, the last update will win.

But still this synchronization solution doesn't seem to help at the file 
level.  Additional thoughts?

Brian



Brian Bonner wrote:

> Hi Guys,
>
> I had a request from someone to allow them to write forms directly to 
> an Excel spreadsheet. This user is not a developer, but does do web 
> design and is fairly fluent with HTML, xHTML.  Anyway.
>
> I have written a tag library to allow read/write access to/from Excel 
> spreadsheets using POI.  It works well, and I know that POI is not 
> threadsafe.
>
> I could synchronize access to calls made by the tags to POI.  But I'm 
> also concerned about a user opening up the file and locking up the app.
>
> Any suggestions?
>


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: Threading (again)

Posted by an...@superlinksoftware.com.
Be real clear on what "not threadsafe means" that means that any given 
instance of HSSFWorkbook is not thread safe.  Meaning multiple threads 
manipulating the same book at the same time.

It is totally fine for mutliple threads to manipulate their OWN instance 
HSFFWorkbook.

This is not like using VBA and Excel where the whole of Excel isn't 
threadsafe (one file at a time).

-Andy

Brian Bonner wrote:
> Hi Guys,
> 
> I had a request from someone to allow them to write forms directly to an 
> Excel spreadsheet. This user is not a developer, but does do web design 
> and is fairly fluent with HTML, xHTML.  Anyway.
> 
> I have written a tag library to allow read/write access to/from Excel 
> spreadsheets using POI.  It works well, and I know that POI is not 
> threadsafe.
> 
> I could synchronize access to calls made by the tags to POI.  But I'm 
> also concerned about a user opening up the file and locking up the app.
> 
> Any suggestions?
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/