Hi, i have certain data which i have to write to the database. Its an insert of records. The problem here is that i dont want to insert into all fields of the database but only those which is needed. I get the error saying "Column count doesn't match value count at row 1" This is a sample of my code.
String query = ("select Name, Leave_Entitlement from tb_employee where emp_ID = '" + userName + "'");
rst = stm.executeQuery(query);
String query1 = "SELECT (A.Leave_Entitlement - sum(B.Duration)) AS BALANCE_LEAVE FROM tb_employee A, tb_leavemc B WHERE A.emp_ID=B.emp_ID AND A.emp_ID = '" + userName + "'";
rst1 = stm1.executeQuery(query1);
String Leave_Type =(String) session.getAttribute("select1");
String Date_from =(String) session.getAttribute("startdate");
String Date_to =(String) session.getAttribute("enddate");
String Reason =(String) session.getAttribute("textarea");
String Duration =(String) session.getAttribute("duration");
String query2 = "INSERT into tb_leavemc VALUES('" + Leave_Type+ "','" + Date_from+ "','" + Date_to+ "','" + Reason+ "','" + Duration+ "',)";
stm2.executeUpdate(query2);
The other fields in the table are
emp_ID - the primary key
Leave_Approval_Status
MC_Serial_No
Status
AmPm