This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQL syntax error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL syntax error" Watch "SQL syntax error" New topic
Author

SQL syntax error

Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I am getting a SQL syntax error when I try to execute an INSERT...INTO command via JDBC. Unfortunately, the message is not very helpful! Maybe I'm just spoiled by the nice messages that Sun's Java compiler gives for my Java code. Anyway, here is the code that causes the error:



And here is the stack trace for the exception:



The SQLUtil class is a nice little utility that takes care of a lot of the complexities of JDBC for me. Also it makes commonly used code very reusable. I won't post it here unless I need. Most of the methods I use here are delegated directly to a PreparedStatement.

Any ideas what the problem is with my SQL statement?

I will greatly appreciate any help.

Layne


Java API Documentation
The Java Tutorial
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

And like Java code, be sure to balance your parentheses.
[ June 08, 2005: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Bear Bibeault:
And like Java code, be sure to balance your parentheses.

[ June 08, 2005: Message edited by: Bear Bibeault ]




Is that all it is! *mutters* Why can't the error message say so! I nice little "expected ')'" shouldn't be too difficult!

Thanks, Bear!!! Once I add a paren, I hope it works.

Layne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL syntax error
 
Similar Threads
Syntax error while inserting a file into Mysql database.
Configuring the Datasource forJBOSS
problem with inser into query
String -> MySQL CLOB
Batch Delete Problem