Closed Thread Icon

Topic awaiting preservation: How to make sure all SQL are executed in JSP (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=12947" title="Pages that link to Topic awaiting preservation: How to make sure all SQL are executed in JSP (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: How to make sure all SQL are executed in JSP <span class="small">(Page 1 of 1)</span>\

 
Pimms One
Bipolar (III) Inmate

From: Australia
Insane since: Jun 2003

posted posted 10-23-2003 03:02

I have a block of SQLS which I need to make sure they execute. How can I ensure that all of them will run in JSP and not interrupted in a multi user environment? That is when user1 run SQL1, SQL2; user2 will not start running SQL1. Do I use synchronisation? Thank you.

-------
SQL1
SQL2
SQL3
SQL4
------

rickindy
Nervous Wreck (II) Inmate

From: Indianapolis, In USA
Insane since: Jan 2002

posted posted 10-23-2003 14:57

Are you looking for some kind of synchronization like Java has? If so, I'm pretty sure that php doesn't have any such feature.
What specifically are you trying to accomplish with this?
There may be a workaround.


Few problems in life can't be solved by chocolate

Perfect Thunder
Paranoid (IV) Inmate

From: Milwaukee
Insane since: Oct 2001

posted posted 10-23-2003 15:10

You want to specify locking in your SQL statements. I don't remember the syntax off the top of my head (and it might be different from database to database), but you want to lock the table before running commands, then unlock it once you're done.

Cell 1250 :: alanmacdougall.com :: Illustrator tips

Rhino
Bipolar (III) Inmate

From: New Jersey, USA
Insane since: Jul 2003

posted posted 10-23-2003 16:23

The two different ways you could do it are by schronizing the method which will run the SQL statements or you could Serialize the Transaction Type to Serialize in the connection. I would probably recommend that you stay away from the threading which can get very ugly. Also, be carefull with Serialization as well because while the tables are locked other will be held in the queue waiting for them to be released.

Pimms One
Bipolar (III) Inmate

From: Australia
Insane since: Jun 2003

posted posted 10-24-2003 02:15

Thank you for all the valuable suggestion.

What I am trying to prevent is that when SQL1 execute, another user also execute the same block of code and thus making the result inconsistant.

Perfect Thunder
Paranoid (IV) Inmate

From: Milwaukee
Insane since: Oct 2001

posted posted 10-24-2003 12:41

Synchronizing the functions in Java isn't a bad idea; but I think you'll get easier and better results if you use SQL's locking feature instead. Each time JSP receives a "table locked" result, just reset the timeout and try again.

Cell 1250 :: alanmacdougall.com :: Illustrator tips

Pimms One
Bipolar (III) Inmate

From: Australia
Insane since: Jun 2003

posted posted 10-27-2003 02:36

Can you please show me the code as how to do a SQL locking? Thank you.

« BackwardsOnwards »

Show Forum Drop Down Menu