Re: concurrency problem - Mailing list pgsql-sql

From Aaron Bono
Subject Re: concurrency problem
Date
Msg-id bf05e51c0606160733s7190a76dq3e4081b82af9d1d@mail.gmail.com
Whole thread Raw
In response to concurrency problem  ("sathish kumar shanmugavelu" <sathishkumar.shanmugavelu@gmail.com>)
List 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.shanmugavelu@gmail.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

pgsql-sql by date:

Previous
From: "Aaron Bono"
Date:
Subject: Re: sessions and prepared statements
Next
From: Geoffrey Knauth
Date:
Subject: Re: listen_addresses = '*' ok, specific address(es) no