• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bauke ! The program is working fine now!
 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic