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 error in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "error in servlet" Watch "error in servlet" New topic

error in servlet

Namrata Kakkar

Joined: Aug 24, 2009
Posts: 6
I have made one html page using javascript.Whenever the control goes to the servlet page it shows database error.

the exception isjava.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.
I am using MS-Access for database

Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

Namrata Kakkar wrote:

if you output the SQL created by above line, you should see the problem. If you don't, try pasting this query into Access and see what happens. That is what I do when I can't make a query work.

Also, you should be using parametrized queries.
Swastik Dey

Joined: Jan 08, 2009
Posts: 1529

I assume account and password are text/character type fields

and the field names used are correct as defined in the table.
However using PreparedStatement is always a better approach.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63552

Moved to the JDBC forum

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: error in servlet
It's not a secret anymore!