This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC 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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
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: 1473

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

Moved to the JDBC forum

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
jQuery in Action, 2nd edition
subject: error in servlet