Re: concurrency problem

From: "Aaron Bono" <postgresql(at)aranya(dot)com>
To: "sathish kumar shanmugavelu" <sathishkumar(dot)shanmugavelu(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: concurrency problem
Date: 2006-06-16 14:33:59
Message-ID: bf05e51c0606160733s7190a76dq3e4081b82af9d1d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I know this is a Java issue but I would recommend something more like:

Statement stmt = con.createStatement();
try {
stmt.execute("begin");
stmt.execute("lock table rcp_patient_visit_monitor");
psSave.executeUpdate(); //psSave is a prepared statement
stmt.execute("commit");
con.commit(); is called
} catch (Exception e) {
con.rollback(); is called
} finally {
stmt.close();
}

On 6/16/06, sathish kumar shanmugavelu <sathishkumar(dot)shanmugavelu(at)gmail(dot)com>
wrote:
>
> Dear all,
> I tried the lock table option today.
> yes it works fine when saving simultaneously.
> but after two or three times even when all of us close our application,
> the lock exists there in the database. when we run the select query from
> other db tool it hangs up.
>
> our code looks like
> Statement stmt = con.createStatement();
> while(true){
> try{
> stmt.execute("begin");
> stmt.execute("lock table rcp_patient_visit_monitor");
> break;
> }catch(SQLException e){
> stmt.execute("commit");
> }
> }
> psSave.executeUpdate(); //psSave is a prepared statement
> stmt.execute("commit");
>
> if saved then
> con.commit(); is called
> if not saved then
> con.rollback(); is called
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Geoffrey Knauth 2006-06-16 14:39:46 Re: listen_addresses = '*' ok, specific address(es) no
Previous Message Aaron Bono 2006-06-16 14:29:13 Re: sessions and prepared statements