File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bauke ! The program is working fine now!
 
Paul Campbell
Ranch Hand
Posts: 338
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic