Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Where's the syntax error in this SQL statement?

    Code:
    public static void editItemType( String itemID, String desc, String catID, String retail, String wholesale, String unitname, String origID ) throws Exception
    {
    
    ...
    
    int newID = Integer.parseInt( itemID );
    int oldID = Integer.parseInt( origID );
    		
    PreparedStatement ps = con.prepareStatement( "UPDATE itemtype SET itemID = ?, desc = ?, catID = ?, retail = ?, wholesale = ?, unitname = ? WHERE itemID = ?" );
    ps.setInt( 1, newID );
    ps.setString( 2, desc );
    ps.setInt( 3, Integer.parseInt(catID) );
    ps.setDouble( 4, Double.parseDouble(retail) );
    ps.setDouble( 5, Double.parseDouble(wholesale) );
    ps.setString( 6, unitname );
    ps.setInt( 7, oldID );
    ps.executeUpdate();
    
    ...
    
    }
    I have an MS Access database with a table named "itemtype" and here are the fields:

    itemID...........Number
    desc.............Text
    catID............Number
    retail.............Number
    wholesale.......Number
    unitname........Text
    quantity.........Number

    I really don't understand how the JSP I'm using says that there is a syntax error in my UPDATE statement. The line that says ps.executeUpdate() is pointed out in the stack trace.

    Where's the error in my UPDATE statement?

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    can you post the stacktrace and the exception that you are getting?
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •