how can we lock the database programmatically,or through help of some JDBC API methods.I am working with Swing for user interface and JDBC 3.0 for connection to database with JDBC-ODBC bridge.My backend is MS SQL Server.
in oracle then it is done like this. try to look for similar queries for ur database.
and when u want to free the lock then u just have to say commit and it is freed.
rahul kumar
Ranch Hand
Joined: Feb 24, 2001
Posts: 75
posted
0
prabhat commiting means something else but what i want is to lock the database. which means that no two queries can be executed simultaneously. by setAutocommit(false) u can't stop simultaneous execution of queries.
rahul kumar
Ranch Hand
Joined: Feb 24, 2001
Posts: 75
posted
0
Pls guys and JDBC Gurus i had to complete my software before 31 march. and had done only 10% of coding. pls tell me is there any way to lock the databse through java( like in ASP there are methods for locking and unlocking database 'connection.lock()' & 'connection.unlock()' ) or there is any other way.
try Connection.setTransactionIsolation(TRANSACTION_SERIALIZABLE); This sets the level of managing potential conflicts that may arise when 2 transactions are operating on a database to the highest level. Jamie [ March 02, 2002: Message edited by: Jamie Robertson ]
I could be mistaken, but I don't believe java has a built in mechanism that will lock a database from access. There are utilites that will allow you to control the type of transaction that can occur on the database(read-only, dirty reads etc.). But I believe you may have to build your own database locking mechanism. Creating a locking mechanism at the database level as opposed to the record level is a little easier. I would suggest you look into creating some kind of flag(on/off) locking mechanism. I hope this helps. Craig
Craig Jackson
Ranch Hand
Joined: Mar 19, 2002
Posts: 405
posted
0
Please, disregard the above comments. I didn't realize I was posting a response to such an old question. Thanks. Craig.