aspose file tools*
The moose likes JDBC and the fly likes SQLException:Column count doesn't match value count at row 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLException:Column count doesn Watch "SQLException:Column count doesn New topic
Author

SQLException:Column count doesn't match value count at row 1

Swapna Gouri Kalanidhi
Ranch Hand

Joined: Mar 14, 2008
Posts: 107
Hi All
I'm trying to insert data into database using Servlets and JSP. Using MySQL database. But I'm getting SQLException : Column count doesn't match value count at row 1. I have verified all the columns and their data types in the database against the one in my Servlet program. Unable to trace the root cause of this error. Here's the program and the stack trace:


Stack Trace:

Table description:


Can any one tell me why we get this error and where my program went wrong?

[ December 22, 2008: Message edited by: Swapna Gouri Kalanidhi ]
[ December 22, 2008: Message edited by: Swapna Gouri Kalanidhi ]

Thanks & Regards
Swapna Gouri
I "try", I "catch" and "finally" WIN !!!
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Not sure about this specific problem, but try to use the full written out insert statement, thus with the column names specified before VALUES.

E.g.
Swapna Gouri Kalanidhi
Ranch Hand

Joined: Mar 14, 2008
Posts: 107
Thanks Bauke ! The program is working fine now!
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Originally posted by Swapna Gouri Kalanidhi:
Hi All
I'm trying to insert data into database using Servlets and JSP. Using MySQL database. But I'm getting SQLException : Column count doesn't match value count at row 1. I have verified all the columns and their data types in the database against the one in my Servlet program. Unable to trace the root cause of this error. Here's the program and the stack trace:

Table description:


Can any one tell me why we get this error and where my program went wrong?

[ December 22, 2008: Message edited by: Swapna Gouri Kalanidhi ]

[ December 22, 2008: Message edited by: Swapna Gouri Kalanidhi ]


Usually when I see this error it is because there is an auto-incrementing column that isn't included in your insert (when you don't specify the column names, the database engine assumes you're providing all of them)... is there a key column you left off your description... if there is and you use the insert without the column names... you have to pass a zero byte column value in the insert... i.e. ''... If you use the column names... you are not impacted by this... and you are also not impacted by table changes to add columns to the table you may not need with your application.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQLException:Column count doesn't match value count at row 1