I'm trying to insert data into my database.. i enter the info into some jtextfields, and then use prepared statements. however, one of the fields(the 4th parameter), needs to be added as a date type into the database. a portion of the code is below:
PreparedStatement patientquery = connection.prepareStatement(
"INSERT INTO patient (Patientid, Name, Sex, Dateofbirth, Address ContactNo values (?, ?, ?, ?, ?, ?");
patientquery.setString(1, fields.pid.getText());
patientquery.setString(2, fields.pid.getText());
patientquery.setString(3, fields.pid.getText());
patientquery.setDate(4, fields.pid.getText());
patientquery.setString(5, fields.pid.getText());
patientquery.setString(6, fields.pid.getText());
patientquery.executeUpdate();
System.out.println("Inserted patient record");
i get the error: java.sql.SQLException: Column count doesn't match value count at row 1
could sumone give me a small sample code how to solve this by convertin that text string to a date type??
thnx in advance..!