This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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 Java Interview Guide this week in the Jobs Discussion 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: 1584

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: 63869

Moved to the JDBC forum

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: error in servlet
jQuery in Action, 3rd edition