Friday, November 25, 2011

Sql Syntax Error

Hai Team,
             while running my project from ecilpse i am getting this following error
1.You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
2.I tried to set the value manually in that case it working fine

Here is my code,tell me that what mistake i have done in that code

  String statement ="INSERT INTO stock (systemno,username,
systemipadd,servicetagno,cpumodel,monitor,webcam,mouse,keyboard,headset,ethernetcable,vgacable,powercable,otherdevices) VALUES('" + sn + "', '" + un + "','" + sip + "','" + sip + "','" + stn + "','" + cpu + "','" + mon + "', '" + web + "','" + mouse + "' , '" + key + "' ,'" + head + "' , '" + enc + "'  ,'" + vgc + "'  , '" + pwc + "' ,'" + oth + "' ,)";
          PreparedStatement stmt = c.prepareStatement(statement);
          stmt.setString(1, sn);
          stmt.setString(2, un);
          stmt.setString(3, sip);
          stmt.setString(4, stn);
          stmt.setString(5, cpu);
          stmt.setString(6, mon);
          stmt.setString(7, web);
          stmt.setString(8, mouse);
          stmt.setString(9, key);
          stmt.setString(10, head);
          stmt.setString(11, enc);
          stmt.setString(12, vgc);
          stmt.setString(13, pwc);
          stmt.setString(14, oth);
          int success = 2;
          success = stmt.executeUpdate(statement);
Thanks
Sasikala

No comments:

Post a Comment