• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

What is wrong with this Update Query!!!!

 
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
This my update query and I don't understand why it gives me error!!!
Please help...
Thanks,
Elahe
PrepStmt=con.prepareStatement("update bug set values (?,?,?,?,?) where bugNumber=?");
PrepStmt.setInt(1,ID);
PrepStmt.setString(2,bdesc);
PrepStmt.setString(3,fixedDate);
PrepStmt.setInt(4,userID);
PrepStmt.setString(5,contact);
PrepStmt.setInt(6,bugNumber);
Error:
--------
You have an error in your SQL syntax near 'values (3,'I can not delete the bug#456','2001-01-01',3,'Rick-408-778-2967') whe' at line 1
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which database are you using? Not all databases support the syntax that you are using. For example, the UPDATE syntax for PostgreSQL is:
UPDATE [ ONLY ] table SET col = expression [, ...]
[ FROM fromlist ]
[ WHERE condition ]

I believe your statement would work with MySQL.
hth,
bear
[ January 23, 2002: Message edited by: Bear Bibeault ]
 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I'm usubg MySql but why it gives me syntax error
 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,I'm using MySql, but why it gives me error
 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got my answer the query should be like this:
PrepStmt =con.prepareStatement("update bug set ID=?,bdesc=?,fixedDate=?,userID=?,contact=? where bugNumber=?");
Elahe
 
Water proof donuts! Eat them while reading this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic