Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

CAN ANY ONE HELP:java.sql.SQLException: Statement parameter 1 not set

807607Jan 24 2007 — edited Jan 24 2007
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)+"<br>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 <br>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");
}
}



}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 21 2007
Added on Jan 24 2007
9 comments
1,016 views