i am having error in following code else condition not working(insert other user) plz fix it and reply it

<% String dcolpoid = "null";
            try {
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                //182.50.131.83    182.50.131.34
                String sURL = "jdbc:mysql://localhost:3306/maxcaredb2011";
                String sUserName = "root";
                String sPwd = "password";
                Connection con1 = DriverManager.getConnection(sURL, sUserName, sPwd);
                out.print("connection" + con1);

                //check valid user


                Statement st = con1.createStatement();

                ResultSet rs = st.executeQuery("select colpoid from salesdetail where colpoid=" + rcolpoid + ";");
                while (rs.next()) {
                    String dbcolpoid = rs.getString("colpoid");
                    if (dbcolpoid.equalsIgnoreCase(rcolpoid)) {
                        //insert for maxcare
                        int done = st.executeUpdate("insert into userregtable(ufname,ulname,uemail,upass,utype,ustatus,sex,grade,orgname,orgtype,function,street,pin,city,country,ph1,ph2,fax,colpoid,manuby,pur_year,ipaddr) values('" + firstname + "','" + lastname + "','" + email + "','" + upass + "','maxcare','done','" + sex + "','" + grade + "','" + orgname + "','" + orgtype + "','" + function + "','" + street + "','" + zipcode + "','" + city + "','" + country + "','" + phon + "','ph2','" + fax + "','" + rcolpoid + "','" + manuby + "','" + year + "','" + ipadd + "')");
                        if (done != 0) {out.print("br<>data is updated for maxcare user");}
                            //send mail to maxcare user
                    else {//insert for other user
                        int done1 = st.executeUpdate("insert into userregtable(ufname,ulname,uemail,upass,utype,ustatus,sex,grade,orgname,orgtype,function,street,pin,city,country,ph1,ph2,fax,colpoid,manuby,pur_year,ipaddr) values('" + firstname + "','" + lastname + "','" + email + "','" + upass + "','other','waiting','" + sex + "','" + grade + "','" + orgname + "','" + orgtype + "','" + function + "','" + street + "','" + zipcode + "','" + city + "','" + country + "','" + phon + "','ph2','" + fax + "','" + rcolpoid + "','" + manuby + "','" + year + "','" + ipadd + "')");
                        if (done1 != 0) {out.print("<br>data is updated  other user"); }
                          }

                                                                }
                                 }
            
            
            }catch (Exception e) {

                out.print("error is " + e.getMessage());
            }
              %>

Do not use scriptlets in JSP.

Do not cobble together statements like that, use a PreparedStatement.

Use a Connection Pool.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.