This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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: 1527

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

Moved to the JDBC forum

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