Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Prepared Statements: setDate type

843854Jun 13 2005 — edited Jun 14 2005
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..!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 12 2005
Added on Jun 13 2005
19 comments
681 views