Why data in my table is not updated?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpuser123
    New Member
    • Dec 2009
    • 108

    Why data in my table is not updated?

    I want to update data from my database using java. I have established my connection successfully and When I am updating the table,the data is not updated in the database.

    My SQL is like this ::

    UPDATE tbl_Bus SET Bus_locX= 520.0,Bus_locY= 220.0 WHERE Bus_ID=1

    This statement does not update my table though it's working fine when I am using it directly in sql editor in MS Access.

    My tbl_Bus
    Bus_ID,Bus_LocX ,Bus_LocY,Bus_R outeID
    and the corresponding data are 1,1,1,1 even after running my app..



    My codes

    Code:
    public boolean update_busLoc(double x,double y,int id){
        String query="UPDATE  tbl_Bus SET Bus_locX= "+ x +",Bus_locY="+y + " WHERE Bus_ID="+id;
        System .out.println(query);
        if (DB_connection!=null){
                try{
                         statement.execute(query);
                         return true;
    
                     }
                catch(SQLException e){
                        e.printStackTrace();
                    return false;
                }
        }
        else{
            System.out.println("Connection is not set up");
            return false;
        }
    
    }
    I use MS Access 2007
    I am able to execute SELECT statements and it is working fine but with update I am having problems..
    How do I sort this out?
Working...