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
Registering a Headset Button Click with Broadcastreceiver in Android
Is Custom Enum Serializable Too
How to Send Data from Dialogfragment to a Fragment
Android Web Scraping with a Headless Browser
How to Reliably Simulate Touch Events on Android Without Root (Like Automate and Tasker)
Android: Realm + Retrofit 2 + Gson
The Type Java.Lang.Charsequence Cannot Be Resolved in Package Declaration
How to Use Jndi Datasource Provided by Tomcat in Spring
Remove Padding/Margin from Javafx Label
How to Programmatically Enable Gps in Android Cupcake
What's a Good Library for Parsing Mathematical Expressions in Java
Android Post Picture to Facebook Wall