• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Pessimistic Locking

 
Ranch Hand
Posts: 290
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Is Pessimistic locking (SELECT...FOR UPDATE ) an ANSI standard or any other standard? Or they are specific extensions from database vendors?

Also can pessimistic locking be achieved using only JDBC API and not using "SELECT ....FOR UPDATE " as part of my queries.

Thanks
Aryan
 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Aryan Khan:
Hi all,
Is Pessimistic locking (SELECT...FOR UPDATE ) an ANSI standard or any other standard? Or they are specific extensions from database vendors?

Also can pessimistic locking be achieved using only JDBC API and not using "SELECT ....FOR UPDATE " as part of my queries.

Thanks
Aryan



Pessimistic locking (and Optimistic Locking) are strategies for dealing with database collisions. They are best practices, not standards or vendor extensions.

You have to use Select for Update for pessimistic locking... however, keep in mind that pessimistic locking is not a scalable strategy. As you add users and transactions... wait for lock situations impact your transactions.
 
Aryan Khan
Ranch Hand
Posts: 290
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul,
If they are not standards ..how can one ensure SQL portability. Many databases does not support "SELECT ...FOR UPDATE".
For concurrency and bottleneck, I agree!!!
Aryan
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are just using JDBC, you'll need to provide per-database implementations for each pessimistic locking syntax. If you are using something like a DAO pattern this shouldn't have too much of an impact.

The alternative would be to use an ORM tool, which will give you portability without having to write per-dataabse code.
 
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic