wood burning stoves*
The moose likes JDBC and the fly likes SQL error 6 - Help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL error 6 - Help!" Watch "SQL error 6 - Help!" New topic
Author

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
KPSUK


Cheers!
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

Hi Kps,
<aside>
Dirk, if this person's name is "Kps", then I'm the Pope!
</aside>
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,
Avi.
[ 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: http://aspose.com/file-tools
 
subject: SQL error 6 - Help!
 
Similar Threads
Method to retrieve information and output in GUI
MSSQL stored procedure with parameters not working
String Tokenizer
insert image path in mysql database
NPE