Dear Saravanan

Just look at your query it's
"select * from userdet where uname = username "

instead it should be
"select * from userdet where uname = " +username ;

I hope this is pretty clear to you now.

Rgds
Sanjay

--
___________________________________________________________
Sanjay Vashisht,
Senior Systems Engineer,
Electronic Commerce & Financial Solutions,
Wipro Technologies,
M.G. Road,
Bangalore - 560 001
Tel : +91-080-5588613 Xtn 460, 434
Tel(Res): +91-080-5212052
Fax : +91-080-5596731,5587984

http://www.wipro.com
World's First SEI CMM Level 5 Software Services Company
___________________________________________________________





********************************Message
Seperator***********************************************
Date:    Thu, 16 Nov 2000 12:10:49 GMT
From:    s saravanan <[EMAIL PROTECTED]>
Subject: Retriving datas using odbc-jdbc connection in servlets

Hi All!

      I'am learning servlets now for my project. I have some doubts
regarding the program which i have written:

Here is my program....
*********************

import java.sql.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class testing extends HttpServlet
{

  public void doPost(HttpServletRequest request, HttpServletResponse
response)throws
ServletException,
IOException

  {

    PrintWriter out=response.getWriter();

    try
   {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:test");

    String username=request.getParameter("un");

    Statement stmt=con.createStatement();
    String query="select * from userdet where uname = username ";
    ResultSet rs = stmt.executeQuery(query);

  while(rs.next())
  {
   out.println(rs.getString(1));
   }


   out.close();
   }
   catch(Exception e)
   {
    out.println(e);
   }
  }
}


****
   Here 'test' is the DSN name. I'am using MS-Access as the database. I
want
get the first column value in the userdet table by using the uname in
the
where condition.

  Actually i'am getting the value in the variable username. That
variable i
equated with the uname in the table. But it shows error saying:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few

parameters. Expected 1.


If i give like:
    select * from userdet where uname = 'ssarav';

   ssarav is the real value in the table. Then it works.

Even if i give like: select * from userdet; This  also works.
But if i give variable name with the equated symbol , it does not work
saying the above error.

Please help me what to do....

Bye,
s.saravanan,
web programmer,
Alpha Systems,
email-id: [EMAIL PROTECTED]

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to