CAN ANY ONE HELP:java.sql.SQLException: Statement parameter 1 not set
import java.io.*;
import javax.servlet.*;
import java.sql.*;
public class UserInfo extends GenericServlet
{
public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
Connection con=null;
PreparedStatement pst=null;
ResultSet rs=null;
try{
con=DriverManager.getConnection("jdbc:mysql://localhost/userdetails","mysql","junit");
pst=con.prepareStatement("select * from user_info where ufn=? and uln=? and ueid=? and uname=? and upass=? and urd=? and uage=? and sem=?; ");
rs=pst.executeQuery();
if (rs.next())
{
out.println("first name"+rs.getString('1')+"Last name"+rs.getString(2)+"email ID"+rs.getString(3)+"Login name"+rs.getString(4)+"password:"+rs.getString(5)+"
Registration Date "+rs.getString(7)+"Users age"+rs.getString(8)+"Employed or not if yes 1 and for No 0"+rs.getInt(6));
//out.println("first name"+rs.getString("ufn")+"Last name"+rs.getString("uln")+"email ID"+rs.getString("ueid")+"Login name"+rs.getString("uname")+"password: masked
Registration Date "+rs.getString("urd")+"Users age"+rs.getString("uage")+"Employed or not if yes 1 and for No 0"+rs.getString("sel"));
return ;
}
}
catch(Exception e){out.println(e);}
finally{try{con.close();}catch(Exception e){out.println(e);}}
}
public void init()throws ServletException
{
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch(Exception e)
{
throw new ServletException("Error while Loading the Driver");
}
}
}
[1742 byte] By [
junita] at [2007-11-26 16:08:04]

pst=con.prepareStatement("select * from user_info where ufn=? and uln=? and ueid=? and uname=? and upass=? and urd=? and uage=? and sem=?; ");
// Between the above and below statements you need to set the variables, using:
// pst.setString(1, myVarHere);
// ... etc.
rs=pst.executeQuery();
... Also not a goot idea generally to use an 'if' statement for the resultset ... usually use a while loop.
You do this in your code
pst=con.prepareStatement("select * from user_info where ufn=? and uln=? and ueid=? and uname=? and upass=? and urd=? and uage=? and sem=?; ");
which creates a sql statement with 8 bound parameters, but then you never bind the parameters to any value. You need to do this:
pst.setString(1,"Bob");
pst.setString(2,"Smith");
pst.setString(3,"bob.smith@mumbojumbo.net");
// etc...
This problem was actually mentioned in your last thread, if you had bothered to read any of it.
~Tim
> u never replied me .. on related subject.
Shut up you stupid ******* idiot. I did too.
http://forum.java.sun.com/thread.jspa?threadID=5128436&tstart=0
REPLY # 2
1) When you post code, please use[code] and [/code] tags as described in [url=http://forum.java.sun.com/help.jspa?sec=formatting ]Formatting tips[/url] on the message entry page. It makes it much easier to read.
2) I don't know what you are saying is not found. More information would be helpful.
3) You had better think of binding some parameters to your PreparedStatement/.
4) Please close your ResultSets and Statements as well as your Connections.
*************************
So stop lying and just piss off. Your code is shite and you are too stupid to fix it.