Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Checking table locks in java  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

i have a problem like, lets say a database table is locked in shared mode.
At that time another thread is trying to put Exclusive lock on it.
so my question is how can you check the type of lock present on a particular table. If we can find out that there is already some lock present on a table, then we can make the second thread to wait for the lock to be released.

Any input on the same will be helpful.

Thanks
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think this cannot be solved in java... still then i am trying to find a solution...
 
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would need to use the database specific stored procedures or views provided by your RDBMS. For example, SQL Server has sp_lock that will give you meta data one the lock. Oracle has v$lock. Check your RDBMS docs.

However, given your requirement, it might be better to catch the SQLException, parse it for the known SQL error code (or whatever) and sleep if it is an locking exception.
 
arabinda baas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot for replying.
i am using informix db.
catching the exception seems to be the easier one.
as java api says getErrorCode() method will display the vendor specific error codes.
Can it happen like informix team uses same error codes for different errors.
 
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!