From: Aaron Bono <postgresql@aranya.com>
To: sathish kumar shanmugavelu <sathishkumar.shanmugavelu@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: concurrency problem
Date: Fri, 16 Jun 2006 09:33:59 -0500
Message-ID: <bf05e51c0606160733s7190a76dq3e4081b82af9d1d@mail.gmail.com> (raw)
In-Reply-To: <ee0ad3a30606160639k7e82465i9bee4a2e17c80fdf@mail.gmail.com>
References: <ee0ad3a30606160639k7e82465i9bee4a2e17c80fdf@mail.gmail.com>
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
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: postgresql@aranya.com, sathishkumar.shanmugavelu@gmail.com
Subject: Re: concurrency problem
In-Reply-To: <bf05e51c0606160733s7190a76dq3e4081b82af9d1d@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox