Topic awaiting preservation: How to make sure all SQL are executed in JSP |
|
---|---|
Author | Thread |
Bipolar (III) Inmate From: Australia |
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. |
Nervous Wreck (II) Inmate From: Indianapolis, In USA |
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. |
Paranoid (IV) Inmate From: Milwaukee |
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. |
Bipolar (III) Inmate From: New Jersey, USA |
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. |
Bipolar (III) Inmate From: Australia |
posted 10-24-2003 02:15
Thank you for all the valuable suggestion. |
Paranoid (IV) Inmate From: Milwaukee |
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. |
Bipolar (III) Inmate From: Australia |
posted 10-27-2003 02:36
Can you please show me the code as how to do a SQL locking? Thank you. |