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]
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
___________________________________________________________________________
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