where can i write in the code to avoid duplicate byyer registration using database using jsp . i mean no multiple entries in database with same name

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


where can i write in the code to avoid duplicate byyer registration using database using jsp . i mean no multiple entries in database with same name



<%



String date="NO";



String uname= request.getParameter("uname");



String fname= request.getParameter("fname");



String lname= request.getParameter("lname");



String password= request.getParameter("pass");



String email= request.getParameter("email");



String phoneno=request.getParameter("phoneno");



String photo=request.getParameter("photo");



try



{



ResultSet rs=null;



int id=0;



int i=0;



String str="USR00";



Connection con=databasecon.getconnection();


Statement st=con.createStatement();

String qry="select max(id) from user";

rs=st.executeQuery(qry);

if(rs.next())

{

i=rs.getInt(1);

i++;

uid=str+i;

System.out.println(uid);

}



//sConnection con=databasecon.getconnection();



PreparedStatement ps=con.prepareStatement("insert into user



values(?,?,?,?,?,?,?,?,?)");



ps.setInt(1,id);



ps.setString(2,uid);



ps.setString(3,uname);



ps.setString(4,fname);



ps.setString(5,lname);



ps.setString(6,password);



ps.setString(7,email);



ps.setString(8,phoneno);



ps.setString(9,photo);



ps.executeUpdate();



System.out.println("==========PS Successfully Registered==========");



String qry1="insert into addvalet(userid,amount) values('"+uid+"','"+amt+"')";



Statement st1=con.createStatement();



st1.executeUpdate(qry1);



System.out.println("==========st1 Successfully Registered===========");



response.sendRedirect("user.jsp?m=success");



//out.print("USER REGISTERED SUCCESSFULLY");



}



catch(Exception e1)



{



out.println(e1.getMessage());



}



%>









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

3rNFd0DPq,O0xWXEsCvAaV RKnvy,ddbl4hpXMpLf986T2yQv
t4OPdcaEeOMfC G,LJm8LrV5sTVhckc0JIlj9Hi,PUyGjL0,W8BHT5i IaYGrJ XSO

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham