File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes got a Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "got a "Comma needed" error when I do this" Watch "got a "Comma needed" error when I do this" New topic
Author

got a "Comma needed" error when I do this

Jian Zhang
Greenhorn

Joined: Aug 30, 2003
Posts: 20
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

Joined: Jul 27, 2002
Posts: 54
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

Joined: May 26, 2003
Posts: 31054
    
232

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')";


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: got a "Comma needed" error when I do this