File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes SQL error 6 - Help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "SQL error 6 - Help!" Watch "SQL error 6 - Help!" New topic

SQL error 6 - Help!

Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
I am trying to get a JSP/Servlet to POST data to a database via a Bean. everything seems to be working fine apart from when the bean tries to INSERT into the database i get this error:
"Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 6"
I think its just a problem with the SQL command:
String insertSQL = "INSERT INTO userInfo (fname,sname,dob1,dob2,dob3,email,telno,address1,address2,address3) VALUES ("+fname+","+sname+","+dob1+","+dob2+","+dob3+","+email+","+telno+","+address1+","+address2+","+address3+")";
But I'm not sure. I think I'm really close to getting this, it's just this last little problem!
Many tahnks

Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

Hi Kps,
Dirk, if this person's name is "Kps", then I'm the Pope!
In case you are unaware, string literals in SQL need to be delimited by single quotes -- which I did not see in the code you posted.
I think a better alternative would be to use a "PreparedStatement" instead of a "Statement", however.
Good Luck,
[ July 16, 2003: Message edited by: Avi Abrami ]
Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
Ooh I have changed Statement to PreparedStatement now I'm getting a new error:
java.sql.SQLException: Driver does not support this function
I guess it's to do with the JDBC driver(s) on Windows.
I agree. Here's the link:
subject: SQL error 6 - Help!
It's not a secret anymore!