Only 49 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Some one help me pLSSSSSSSSSSSsssssss  RSS feed

 
vikram nalagampalli
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
The following is the error when i am trying to authenticate my user id and password. It says TOO FEW PARAMETERS EXPECTED 1. What does this mean.
I have this assignment due tommorrow, some one pls help me. I am also enclosing my JSP code after the error code.
javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459)
at _0002fLoginHandler_0002ejspLoginHandler_jsp_6._jspService(_0002fLoginHandler_0002ejspLoginHandler_jsp_6.java:177)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)
CODE:
<%@ page session="true" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.lang.String" %>

<%
String userId = request.getParameter("userID");
String password = request.getParameter("password");
%>
<%
String driver="sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc dbc:Alumni1";

Class.forName(driver);
Connection con=null;
try{
con=DriverManager.getConnection(url);
String query="SELECT Ssn, Password FROM Authentication "
+"WHERE Ssn ="+userId+" AND Password="+password;
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(query);

if (rs.next()){
session.setAttribute("Ssn",userId);
%>
<jsp:forward page="Welcome.jsp"/>
<% }else{ %>
<jsp:forward page="Login.jsp"/>
<%
}
rs.close();
rs=null;
stmt.close();
stmt=null;
}
finally{
if(con!=null){
con.close();}
}
%>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should always surround string literals in SQL statements with single-quote characters.
You might also want to investigate the use of PreparedStatement rather than a Statement, which takes care of a lot of these kind of issues.
(I'm biting my tongue about the wisdon of performing SQL directly from a JSP page -- but apparently not hard enough).
hth,
bear
 
Biju Nair
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think ur query should be
String query="SELECT Ssn, Password FROM Authentication "
+"WHERE Ssn ='"+userId+"' AND Password='"+password+"'";
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!