File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Column count doesn't match Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Column count doesn Watch "Column count doesn New topic

Column count doesn't match Exception

Tarun Oohri
Ranch Hand

Joined: Feb 20, 2013
Posts: 189
Hello Everyone
I am trying to insert data from a form into mysql in java but i am getting SQL Exception stating = "Column count doesn't match value count at row 1".
Code i am using is as follows :
I think the mistake is in the values bracket. Please correct me where i am wrong.
Thanks in Advance!!
Martin Vajsar

Joined: Aug 22, 2010
Posts: 3733

I'd say you're missing commas between the values. But you should use PreparedStatement (⇐ read why) instead anyway:

(I'd use executeUpdate instead of execute for an INSERT statement, but the PreparedStatement part is much more important.)
I agree. Here's the link:
subject: Column count doesn't match Exception
It's not a secret anymore!