File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programming Diversions and the fly likes List Updation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "List Updation" Watch "List Updation" New topic
Author

List Updation

Sameer Jamal
Ranch Hand

Joined: Feb 16, 2001
Posts: 1870
I have a List of items which is updated by several users at the same time.
Every user has got a module which continiously checks for the updation. The problem with the logic is every time it checks for the update it traverse the complete table and find out the items that has been not listed and update the list. I dont want to traverse the complete table as it takes lot of time, just want to find out the item which has been most recently added in the table, to do this I tried to add the most recent item on the list based on date and time but again I found that many time more than one user update the list simultaniously and it causes the only one item to be updated can you give me an idea how should I do that without traversing the complete table?.
Arjunkumar Shastry
Ranch Hand

Joined: Feb 28, 2005
Posts: 986
{
....based on date and time but again I found that many time more than one user update the list simultaniously and it causes the only one item to be updated
}
So what is the problem? You have to search for that record with max(timestamp),right?


Namma Suvarna Karnataka
Sameer Jamal
Ranch Hand

Joined: Feb 16, 2001
Posts: 1870
Originally posted by Arjunkumar Shastry:
{
....based on date and time but again I found that many time more than one user update the list simultaniously and it causes the only one item to be updated
}
So what is the problem? You have to search for that record with max(timestamp),right?


Problem is that suppose one user is updating the table at
1-1-05 12:00:00 AM with "item no 1" meanwhile second user is also updating the table with item2, my module will check for the record with maximum date time stamp which will be at present item1(item no 2 is not added yet) now third user have updated the table with item3 at 1-1-05 120:00:01 now next time when module will check for latest update it will return "item no 3", "item no 2" is lost.



[ September 21, 2005: Message edited by: Sameer Jamal ]
Arjunkumar Shastry
Ranch Hand

Joined: Feb 28, 2005
Posts: 986
Its a database table,right? Write Stored procedure to scan entire table and call stored procedure from your java code.
Sameer Jamal
Ranch Hand

Joined: Feb 16, 2001
Posts: 1870
Originally posted by Arjunkumar Shastry:
Write Stored procedure to scan entire table and call stored procedure from your java code.


That is what I dont want to do even stored procedure take some time to traverse the complete table any other idea ?.
Arjunkumar Shastry
Ranch Hand

Joined: Feb 28, 2005
Posts: 986
On an average,whats the row count of a table daily?
Which database are you using?
Sameer Jamal
Ranch Hand

Joined: Feb 16, 2001
Posts: 1870
Originally posted by Arjunkumar Shastry:
On an average,whats the row count of a table daily?
Which database are you using?


SQL Server
Row count is > 10K


Now it has become Database question this thread might move to General Computing
Arjunkumar Shastry
Ranch Hand

Joined: Feb 28, 2005
Posts: 986
I think it will be moved to JDBC if I am not wrong.
Sameer Jamal
Ranch Hand

Joined: Feb 16, 2001
Posts: 1870
Originally posted by Arjunkumar Shastry:
I think it will be moved to JDBC if I am not wrong.


Lets talk about logic and keep it here
Amit Agrawal
Ranch Hand

Joined: Aug 23, 2001
Posts: 282
for this one, probably i would have kept only an application scope object which will hold replica of database list.

all users should refer to same object so that they don't have any local copies.

now i will sync only one object with database so that individual list do not require sync.

as far as getting one object in sync is concerned...two easy ways will be:

1) whenever any user updates the list, i will update object and database as one logical transaction so that i don't have to read back from database and my object remains updated (except the scenario when appication needs re-initialization when object can be reloaded from database).

2) other way can be that there is a check bit in either database or in the list which tells which ones are new entries. the system than can sync up those entries..

does that make any sense?
Sameer Jamal
Ranch Hand

Joined: Feb 16, 2001
Posts: 1870
Thanks Amit its a good suggestion but sharing a global object among various users slow down the things little bit but its a good idea.

Another approach in my mind was building a seperate table for list updation every time a new item is added it will also be added into that table for each logged on user , user will then check the item from that table and delete their corresponding entry when the list is updated.
Amit Agrawal
Ranch Hand

Joined: Aug 23, 2001
Posts: 282
Originally posted by Sameer Jamal:
Thanks Amit its a good suggestion but sharing a global object among various users slow down the things little bit but its a good idea.

Another approach in my mind was building a seperate table for list updation every time a new item is added it will also be added into that table for each logged on user , user will then check the item from that table and delete their corresponding entry when the list is updated.


well my thoughts on having global object:

in your current design, probably each user has got one object which i think will ultimately be maintained in the server only. All objects shall occupy more or less same amount of memory.

To my mind, it will occupy much more space in the server if you have one object per user than having one global object. i am not sure why do you think gloabl object will slow down anything in comparison to previous design!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: List Updation
 
Similar Threads
3 client types for locking
Check box opens new window and checks a new box
Design question
multiple form question
Sending response to client with out receving request