Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

got a "Comma needed" error when I do this

 
Jian Zhang
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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
 
Rudy Dakota
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • 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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34195
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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')";
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic