Forums Register Login

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

+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Thanks Bauke ! The program is working fine now!
+Pie Number of slices to send: Send
 

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.
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 29560 times.
Similar Threads
MySQLSyntaxErrorException
Control not entering the while loop !
Populating Drop Down List in Servlet
jsp insert into database error(java.lang.NumberFormatException: For input string: "")
java.sql.SQLException: Parameter index out of range (1 > number of parameters, which
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 22:38:33.