Thread: Autocommit Problem

Autocommit Problem

From
"mp.rajkhowa"
Date:
hello

i am developing an application using tomcat 5.5.6 and postgrsql7.3 (pg73jdbc3.jar) deployed in RedHat linux.  Three days earlier updated a column of particular row in a table . When i retrieved the same row from the JSP page it was showing OK.Even when i run the select statement for the row in postgresql console it was showing updated value. But today that means after 3 days when i try to view the row  it  is showing the  old value of row.  When i run the select statement for the row in postgresql console it is showing the old value. How can it happen?Can you please help me out. My java code for the updation is shown below.....
 
        String sql = "UPDATE ........";
      Connectioncon =DBConnection.getConnection(); // DBConnectio is aclass forgetting theconnection
        Statement stmt = con.createStatement();
        // Update a row
        try {
             con.setAutoCommit(false);
             int rowsUpdated = stmt.executeUpdate(sql);
             if (rowsUpdated != 1) {
               System.out.println("Success");
            }
           con.commit();
        }
        finally {
            stmt.close();
        }


with regards
Mridu Pobon Rajkhowa

Re: Autocommit Problem

From
Markus Riehl
Date:
Mridu,

this row doesn't make sense:

              if (rowsUpdated != 1) {

I'm sure this should be

              if (rowsUpdated == 1) {

Kind regards

Markus

mp.rajkhowa schrieb:
> hello
>
> i am developing an application using tomcat 5.5.6 and postgrsql7.3
> (pg73jdbc3.jar) deployed in RedHat linux.  Three days earlier updated
> a column of particular row in a table . When i retrieved the same row
> from the JSP page it was showing OK.Even when i run the select statement
> for the row in postgresql console it was showing updated value. But
> today that means after 3 days when i try to view the row  it  is showing
> the  old value of row.  When i run the select statement for the row in
> postgresql console it is showing the old value. How can it happen?Can
> you please help me out. My java code for the updation is shown below.....
>
>         String sql = "UPDATE ........";
>       Connectioncon =DBConnection.getConnection(); // DBConnectio is
> aclass forgetting theconnection
>         Statement stmt = con.createStatement();
>         // Update a row
>         try {
>              con.setAutoCommit(false);
>              int rowsUpdated = stmt.executeUpdate(sql);
>              if (rowsUpdated != 1) {
>                System.out.println("Success");
>             }
>            con.commit();
>         }
>         finally {
>             stmt.close();
>         }
>
>
> with regards
> Mridu Pobon Rajkhowa