PDA

View Full Version : So I have this web application and I need to create a "mini" version of it...


davidc2
07-05-2007, 09:45 PM
We have this application, it's running on JRun 4, it's using jsp and connects to an SQL database.

What I need is to create a mini version of the application so people can use it on their computers (without having a connection) and then -when they connect to the Internet- update the database.

I need a little guidance on what would be the best thing to do here... Just point me in the right direction :)

Let me know if I'm not explaining myself right or if you need more details please, thanks.

davidc2
07-05-2007, 09:59 PM
So the mini application would have for example something like "add product" then when it connects to the database it would add that product to the database...

Another issue I think will come up is:
Person A adds product X to his computer with product_id = 1.
Person B adds product Y to his computer with product_id = 1.

On the database we have a product_id field (column), now how can I avoid overwriting... Right now all I can think of is an if statement... I don't know I'm not thinking straight I guess :)

Gox
07-06-2007, 12:48 AM
I'm not sure what the "best" way to do this is, but I'll give you one suggestion.

When there's no connection and a person Adds a product you could dump whatever information is needed to a file. Then when a connection is established run through the file and insert the products into the database.

If the file is properly formatted then you should be able to do the following:

While(End of File not reached)

String attribute1 = read from file
String attribute2 = read from file
...

InsertInto(attribute1, attribute2, ...)


Is product ID you're primary key for the table? If it is then I believe the database should enforce it to be unique. Hence, if Person A inserts Product ID = 2, and then Person B tries to do the same thing, then the insert by Person B should automatically be rejected since the Product ID is already in the table.

Alternately you can query the database for the Product ID and if it exists already don't insert.

davidc2
07-06-2007, 03:10 AM
So I could provably create a file that has all the queries on the client's computer.. ? and then just have them send it or add a module to the system so they can 'run it'... this might work

The file would have something like
insert x where.... blah blah blah...

That would give the users the table details though... but since it's "INSERT blah blah blah" I'm thinking it's not an issue the id thing... 'cause sql would do that automatically..

That's an idea... Any other suggestions?

edit: Actually the file doesn't need to have the queries... That could be hidden... but it's a java server so how could I hide this? I don't know if jsp shows the db connection details to the user, does it? hope not, 'cause if not then this would be a piece of cake (I hope :))

edit2: Another thing I've been thinking about...
What if during the 'batch input', i.e. when the products are beeing entered into the system, the system crashes, how can I mark that 'crash point' or something that makes me be able to avoid going through the logs to see when (during the batch) the crash happened.