Java.Sql.Sqlexception: Column Count Doesn't Match Value Count at Row 1

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

There is something wrong with:

String Query_String = "INSERT INTO tablename(field1,field2) VALUES ('"+Text1+","+Text2+"')";

You've missed some quotes between Text1 and Text2:

String Query_String = "INSERT INTO tablename(field1,field2) VALUES ('"+Text1+"','"+Text2+"')";

java.sql.SQLException: Column count doesn't match value count at row 1 error

This is the query that you're running:

insert into class(name, strength ,room, section) values ('" + cname + "','" + cstrength + "','" + croom + "','" + csection + "', CURDATE());")

you've mentioned 4 column values to be passed (class(name, strength ,room, section)), but then you're passing in 5 values (an extra value for CURDATE())

Either add that new column in the table and update the query to include that column as well (i.e. (class(name, strength ,room, section, curdate))) OR remove CURDATE().

java.sql.SQLException: Column count doesn't match value count at row 1 jdbc

netbeans evaluates the field in different way in mysql cmd if you would type this syntax say
insert into user ('username', 'password') values ('xyz', 'abc');
it would work perfectly fine but in netbeans the tables and field names are indicated not in single quotes but in `` this type of quotes so this would perfectly fine in netbeans
insert into user (username, password) values ('xyz', 'abc');
where string like xyz and abc are expressed in single quotes...



Related Topics



Leave a reply



Submit