• Post Reply Bookmark Topic Watch Topic
  • New Topic

Radiobuttons & comboxes in an SQL query  RSS feed

Donna Harrington
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,
I have 3 radio buttons and i'm trying to insert the values of the radio buttons. I also have 3 combo boxes for date,month,year.

In my database i have my radio buttons set to varchar and my combo boxes date,month,year are varchar also..but i dont know if this is the right way.
I also don't know if my SQL statement is right.
I'm getting this error when i compile program

java.sql.SQLException: General error, message from server: "Column count doesn't match value count at row 1"


String radio = request.getParameter("radiobutton");
String Username = request.getParameter("Username");
String Password = request.getParameter("Password");
String FirstName = request.getParameter("FirstName");
String Surname = request.getParameter("Surname");
String Address = request.getParameter("Address");
String City = request.getParameter("City");
String Email = request.getParameter("Email");
String telephoneNum = request.getParameter("TelephoneNum");
String radioB = request.getParameter("radiobutton");
String cardNum = request.getParameter("cardNum");
String date = request.getParameter("date");
String month = request.getParameter("month");
String year = request.getParameter("year");
String radioBtn = request.getParameter("radiobutton");
String shipName = request.getParameter("shipName");
String shipSurname = request.getParameter("shipSurname");
String shipAddress = request.getParameter("shipAddress");
String shipCity = request.getParameter("shipCity");
String shipCountry = request.getParameter("shipCountry");
String shipPostalCode = request.getParameter("shipPostalCode");
String driver="com.mysql.jdbc.Driver";
String connectionURL="jdbc:mysql://localhost:3306/petshopwebsite";
ResultSet rs = null;
String password = "";
String username ="root";

//connection code

PreparedStatement p = con.prepareStatement("INSERT INTO customerdetails(Title,Username,Password,FirstName,Surname,Address,City,Email,TelephoneNum,cardType,
int affectedRows= p.executeUpdate();


[Edited by Jeanne to add linebreaks]
[ May 31, 2004: Message edited by: Jeanne Boyarsky ]
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well - you KNOW your statement is incorrect when you get an error.
'Column count does not match' means 'Column count does not match' - it's always a good idea to read the errormessage and to interpret it.

Here I found the suspicious columns - 3 and 4.

It would be nice, if you edit your post (pencil-paper-icon), and insert some spaces in the very long rows, to give the program working in the background a chance to split them - thanks.
Bear Bibeault
Author and ninkuma
Posts: 66261
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you are using a PreparedStatement (good) why are you in-lining the values (bad) rather than using the '?' placeholders and setting the data with resultSet.set methods?
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!