delete « Database « JSP-Servlet Q&A





1. Problems on deleting a user from my DB    coderanch.com

Hi i just dont get the servlets and jsp... [Edit: removed not-so-nice text. Please be more circumspect in future posts.] So i was wondering why i cant delete a user from my DB(im using mySQL). First here is my jsp <%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> Baja de Usuarios ...

3. How to delete the row from the Database by using while loop in servlet    coderanch.com

import java.lang.*; import java.io.*; import java.sql.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class JdbcDeleteServlet extends HttpServlet { String dbn,dbp,dbco; String un,up,uco; boolean flag=false; public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException { try { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); response.setContentType("text/html"); un=request.getParameter("uname"); up=request.getParameter("pwd"); uco=request.getParameter("code"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c=DriverManager.getConnection("jdbc:odbc:hari","raman","raman"); Statement s=c.createStatement(); s.execute("select *from jduser"); ResultSet rs=s.getResultSet(); while(rs.next()) { dbn=rs.getString("users"); dbp=rs.getString("pass"); dbco=rs.getString("code"); if(un.equals(dbn)&&up.equals(dbp)&&uco.equals(dbco)) // ...