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]
# 1

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.

abillconsla at 2007-7-8 22:30:23 > top of Java-index,Java Essentials,Java Programming...
# 2

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

SomeoneElsea at 2007-7-8 22:30:23 > top of Java-index,Java Essentials,Java Programming...
# 3
ha ha ha ha ha ha ha.Go away Junit. You are hopeless.
cotton.ma at 2007-7-8 22:30:23 > top of Java-index,Java Essentials,Java Programming...
# 4
And stop assigning duke dollars that you have no intention of ever awarding to all your threads. It's dishonest and slightly annoying to be honest.
cotton.ma at 2007-7-8 22:30:23 > top of Java-index,Java Essentials,Java Programming...
# 5
You didn't supply a value for the 'ufn' column in your query; and if you havedone so you'd be surprised again ...kind regards,Jos
JosAHa at 2007-7-8 22:30:23 > top of Java-index,Java Essentials,Java Programming...
# 6
And use the ******* code tags next time you stupid wank. I told you that in the last thread too.
cotton.ma at 2007-7-8 22:30:23 > top of Java-index,Java Essentials,Java Programming...
# 7
> And stop assigning duke dollars that you have no> intention of ever awarding to all your threads. It's> dishonest and slightly annoying to be honest.There seems to be a rash of that going around of late ...
abillconsla at 2007-7-8 22:30:23 > top of Java-index,Java Essentials,Java Programming...
# 8
u never replied me .. on related subject.stop passing comments....
junita at 2007-7-8 22:30:23 > top of Java-index,Java Essentials,Java Programming...
# 9

> 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.

cotton.ma at 2007-7-8 22:30:23 > top of Java-index,Java Essentials,Java Programming...