Record lock - SQL Server 2005

Discussion in 'Java' started by hemaraj_dv.2005@yahoo.co.in, Sep 11, 2007.

  1. Guest

    Hello

    The back end of my Java application is SQL Server 2005, in multi user
    environement.

    There are few counters stored in a table. Each record that is
    created , looks up the relevant counter field, uses it, updates it
    (adds one) and writes it back to db.

    To ensure that while a counter is read by some user, it can not be
    read by another until the first user is done with it, is it enough to
    use


    conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED );



    and this will create the record lock so two user can not access at
    same time, or other process is also needed?

    For example anything else from java side or any setting from SQL
    Server 2005?

    Thank you
    Hemaraj
    , Sep 11, 2007
    #1
    1. Advertising

  2. wrote:
    > The back end of my Java application is SQL Server 2005, in multi user
    > environement.
    >
    > There are few counters stored in a table. Each record that is
    > created , looks up the relevant counter field, uses it, updates it
    > (adds one) and writes it back to db.
    >
    > To ensure that while a counter is read by some user, it can not be
    > read by another until the first user is done with it, is it enough to
    > use
    >
    > conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED );
    >
    > and this will create the record lock so two user can not access at
    > same time, or other process is also needed?
    >
    > For example anything else from java side or any setting from SQL
    > Server 2005?



    You should a SQLServer expert.

    My understanding is that either:

    you use transaction isolation level serializable

    or:

    you select WITH (TABLOCKX) in your sql statement.

    Arne
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=, Sep 15, 2007
    #2
    1. Advertising

  3. derek Guest

    are you trying to generate unique ids for each record? is that why you are keeping a counter? if so, why not just use an identity column?
    derek, Sep 15, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Juan T. Llibre
    Replies:
    0
    Views:
    441
    Juan T. Llibre
    Jun 7, 2005
  2. Fuzzyman
    Replies:
    3
    Views:
    476
    Andrew MacIntyre
    Dec 5, 2003
  3. farseer

    SQL Server 2005 + SQL Server Express

    farseer, Aug 7, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    333
    farseer
    Aug 8, 2006
  4. Wesley Chen
    Replies:
    0
    Views:
    208
    Wesley Chen
    Apr 7, 2009
  5. Wesley Chen
    Replies:
    9
    Views:
    235
    Sean O'Halpin
    Apr 14, 2009
Loading...

Share This Page