Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL error 6 - Help!

 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic