Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Record lock - SQL Server 2005

Reply
Thread Tools

Record lock - SQL Server 2005

 
 
hemaraj_dv.2005@yahoo.co.in
Guest
Posts: n/a
 
      09-11-2007
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.TRANSACTIO N_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

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      09-15-2007
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.TRANSACTIO N_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
 
Reply With Quote
 
 
 
 
derek
Guest
Posts: n/a
 
      09-15-2007
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?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remote connect to the SQL server 2005 when th ere is a‘\’ in the SQL server name, such as 192.168.0.1 1\active? Wesley Chen Ruby 0 04-07-2009 10:23 AM
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com ASP .Net 0 05-03-2008 12:43 PM
MCITP SQL Server 2005 or SQL Server 2008 Darrilgibson@gmail.com MCITP 0 12-19-2007 01:56 PM
SQL Server 2005 + SQL Server Express farseer ASP .Net 3 08-08-2006 04:07 AM
Wohoo! VS.NET 2005/ASP.NET 2.0/SQL Server 2005/BizTalk Server 2006 will launch week of Nov. 7 Juan T. Llibre ASP .Net 0 06-07-2005 05:19 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57