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