I have these databases
h1
h2
h3
Where each database has the quantity of items that are available to be sold from shop1, shop2 and shop3. I want my data to be concurent. For example 2 users may want to buy the same item the same time and the manager want to change the quantity the same time. I want to ensure that the manager will change the quantity first and then one of the user will try to buy the item and them the other although they will try together. I want to be sure that the items that will be sold will be excactly as many as the manager wants.
I am using mysql and jsp to do this.
Where i can find informations about that or an example would be better
When the user decide reserve the item-> pay it and can do it for many items of the site

Recommended Answers

All 3 Replies

Member Avatar for LastMitch

Where each database has the quantity of items that are available to be sold from shop1, shop2 and shop3. I want my data to be concurent. For example 2 users may want to buy the same item the same time and the manager want to change the quantity the same time. I want to ensure that the manager will change the quantity first and then one of the user will try to buy the item and them the other although they will try together. I want to be sure that the items that will be sold will be excactly as many as the manager wants.

The way you post your question it's more related to a e-comm website code rather than a database issue?

Another words you are asking for a code that you can used for your e-comm website not just a query issue.

OK since you mention concurency data which one? There are 2 concurency methods:

http://msdn.microsoft.com/en-us/library/ms189132%28v=sql.105%29.aspx

You can try this and used this:

http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html

i have to do these queries
->sql1: Check availability
->sql2: if (available) charge user
->sql3: if (user was charged) reduce the available items
->sql4: insert the order to db
Is there a way to do all these query as a block and be sure that only one user do it each moment and not two together?
Thank for the links:P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.