• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

got a "Comma needed" error when I do this

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String insertTopic="INSERT INTO T_TOPIC VALUES (TOPICSEQ.NEXTVAL,'"+
topic+"',0,'unchecked'";
String insertItem="INSERT INTO T_ITEM VALUES (ITEMSEQ.NEXTVAL, '"+item+
"','"+picName+"','"+desc+"',null,null,null,'unchecked','"+
topicID+"','"+userID+"'";



stmt.executeUpdate(insertTopic); //where the error being thrown
stmt.executeUpdate(insertItem);
}
catch(SQLException e)
{

e.printStackTrace();
}
Error says ORA-00917: comma needed.
apparently this is the insertTopic string's problem , but I don't think I forget any comma in the string. Anybody who has a sharp eye can find it for me ,please?
Thanks a lot
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
Don't see it either. Your quickest solution will probably be to just print the sql statements to standard output. That should give you an exact insight on what 's happening.
Now that I write this: could one of your variables contain a quote? That might be a reason for this, I think. One more illustration always to use PreparedStatements.
Good riding,
Rudy.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jian,
You are missing the closing parenthesis at the end of the statement. It should be:

String insertTopic="INSERT INTO T_TOPIC VALUES (TOPICSEQ.NEXTVAL,'"+
topic+"',0,'unchecked')";

 
Alas, poor Yorick, he knew this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic