Share on Google+Share on Google+

Ramanjaneyulu Manam
How to delete the row from the Database by using servlet
4 Answer(s)      6 years and a month ago
Posted in : JSP-Servlet

Dear Sir/Madam

I am trying to delete the one user data in the Oracle SQL server database by using servlet program (Tomcat server).

The given data is true then the user data to be delete from the database table.

Assume in Database table have 25 users details are there.

I am given 6th (some n th row)user details true values even though while loop is not terminate, it checking until the end of table and always given else black statement. So what is my mistake in while loop explain and please give the solution to me.

My programe is:

import java.lang.*;

import java.io.*;

import java.sql.*;

import java.util.*;

import javax.servlet.*;

import javax.servlet.http.*;

public class JdbcUpdateServlet extends HttpServlet

{

    String name,pas,cde;

    String un,up,co;

    boolean flag=false;

     public void doGet(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");

            co=request.getParameter("code");

            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

            Connection c=DriverManager.getConnection("jdbc:odbc:hari","raman","raman");

            Statement s=c.createStatement();

            s.executeQuery("select *from jduser");

            ResultSet rs=s.getResultSet();

            while(rs.next())

              {
                   name=rs.getString(1);
                   pas=rs.getString(2);
                   cde=rs.getString(3);
                    if(un.equals(name)&&up.equals(pas)&&co.equals(cde))
                    {
                        flag=true;
                        s.executeUpdate("delete from jduser where code='"+un+"'");
                        break;
                    }
              }
              if(flag==true)
                out.println(name+" User Data deleted successfully");
              else
                out.println("Sorry "+un+" user data is Not Available");

            s.close();
            c.close();
            out.close();
        }
        catch(IOException e)
        {
            System.out.println(e.getMessage());
        }
        catch(SQLException e)
        {
            System.out.println(e.getMessage());
        }
        catch(ClassNotFoundException e)
        {
            System.out.println(e.getMessage());
        }

    }
}

Ads

View Answers

March 2, 2011 at 3:06 PM


Please visit the following link:

Delete row from database using servlet



March 3, 2011 at 12:30 AM


In that link solution is not sufficient to my problem.

I want in while loop when if condition is true then only remove one user data and terminate the while loop.

Before it check the values one by one in the table if match then remove.



March 3, 2011 at 12:39 AM


Same problem with full details (HTML Page, Database table, Servlet Program) see this link

link text



July 22, 2011 at 10:42 PM


Try this All the best

deletetest.jsp

        < input type=checkbox name="check" value="<%=rsselqry.getString(2)%<" <  
        < input type="submit" value="Delete" <  

        **del.jsp**  
         d =request.getParameterValues("check");  

         if(d !=null)  
         {  
           for(int i=0;i<d.length;i++)  
           {  
           k=(String)d[i];  
           out.println(k);  
          }  


         }  

          stmtselqry.executeUpdate("delete from mail where name='"+k+"'");  









Related Tutorials/Questions & Answers:
How to delete the row from the Database by using servlet
How to delete the row from the Database by using servlet  Dear Sir...: Delete row from database using servlet   In that link solution... then the user data to be delete from the database table. Assume in Database table have
How to delete the row from the Database by using while loop in servlet
How to delete the row from the Database by using while loop in servlet ... server database by using Servlet program (Tomcat server). In Database table.... It is Urgent...  When you retrieve the data from the Database by using
Advertisements
Delete a row from database by id
Delete a row from database by id  I m creating a small application using servlet. There is a form (index.jsp)having 10 fields on submitting the form...) for "DELETE" AND "UPDATE". On clicking delete which is hyper link that particular row
delete row from a table using hibernate
delete row from a table using hibernate  //code in java file String hql="delete from CONTACT c where ID=6"; Query query=session.createQuery... [delete from CONTACT] int i=query.executeUpdate
how to delete a row in sql without using delete command.
how to delete a row in sql without using delete command.  how to delete a row in sql without using delete command. thanks in advance
sqlite database delete row
sqlite database delete row  How to delete row from SQLite Database?    NSString *updateSQL = [NSString stringWithFormat: @"DELETE FROM aListDB WHERE id='%@'",details.ids
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
delete row from a table in hibernate
delete row from a table in hibernate  is there method to delete row in a table using hibernate like save(-) to insert row
delete row using id
delete row using id  package pkg2; import org.hibernate.Query; import... = "delete from Insurance insurance where id = 2"; Query query = sess.createQuery...()); } } } this is the code m using . Error is -query must begin with SELECT or FROM
how to display a table from database using servlet
how to display a table from database using servlet  how to display a table with values from servletpage   Hi Friend, Please go through the following link: http://roseindia.net/jsp/servlet-jsp-data-list.shtml Thanks
how to delete specified coloumn from database(MS Access) by using windows application
how to delete specified coloumn from database(MS Access) by using windows application  how to delete specified coloumn from database(MS Access) by using c# windows application
JDBC ResultSet Delete Row Example
JDBC ResultSet Delete Row Example: Learn how to delete row using ResultSet. We are also used ResultSet object with update capability for delete rows from.... 6. Finally call deleteRow() ResultSet method for delete the current row form
How to insert or delete records in MS access database using jsp - JSP-Servlet
How to insert or delete records in MS access database using jsp  Hi friends please provide me a solution that i insert or delete record from a database using java server pages. I used the microsoft access 2003 database. PlZ
delete an item from database
delete an item from database  how to delete an item from the database using jsp
delete multiple row using checkbox
delete multiple row using checkbox  delete multiple row using... fields bookid,author and title in the database. 1) Create book.jsp <[email protected]..=null; st=conn.createStatement(); rs = st.executeQuery("select * from book"); int
How to insert image in sql database from user using servlet
How to insert image in sql database from user using servlet  pls tell me accept image from user and insert image in sql server 2005 database using servlet and jsp
How to update,Delete database values from jtable cells ..
How to update,Delete database values from jtable cells ..  hello Sir... from database into jtable of a jpanel.. Now Sir, According to my need i have... to a particular cell will be updated into database and if we want to delete
Delete a Specific Row from a Database Table
Delete a Specific Row from a Database Table   ..., and in this section we are going to do the same that is, how to delete a specific row... the connection we are going to delete a specific row from the table. If the row
How to get the data from the database using Servlet or JSP program
How to get the data from the database using Servlet or JSP program  ... the problem   Get data from database using servlet Retrieve data from database using JSP Get data from database using JSP
How to Open Picture From M.S. Access Database using Java Servlet ?
How to Open Picture From M.S. Access Database using Java Servlet ?  ... Database But i m still not able to open this picture through Java using M.S. Access and i wants to open this Picture On Web Browser using Java Servlet anybody can
delete row
delete row  how to delete row using checkbox and button in php...("sourabh", $link); $rows=mysql_query("select * from sonu"); $row=mysql... if(isset($_POST['delete'])) { for($i=0;$i<$row;$i++) { $delete
Delete points from database
Delete points from database  I have a polygon on a web page and a delete button. The polygon is saved in the database in one table and in another...: mysqlquery("DELETE FROM polygon WHERE ID=".$GET['ID']."") or die(showsqlerrors(mysql
How to update,Delete database values from jtable cells ..
How to update,Delete database values from jtable cells ..  Hello Sir, I am working on a project in which i have to fetch the values from database to jtable .Now as per my requirement i need to update and delete the database
How to update,Delete database values from jtable cells ..
How to update,Delete database values from jtable cells ..  Hello Sir... from database to jtable .Now as per my requirement i need to update and delete the database records from the table cells by entering new values there only
How we delete a data of database from front end jsp page
How we delete a data of database from front end jsp page   I make a website and featch a data from data base and now i want that a delete button put... deleted from jsp page as well as from database.I used mysql and jsp. Please help me
Delete row and column from table through java code
will see how to delete row and column from given table through java code. Java code... Delete row and column from table through java code...) from stu_info"); rs.next(); // This sql query delete the row having
Update delete perticular row from brower on link - Struts
Update delete perticular row from brower on link   how can update and delete perticular row from List of employee in brower format are ramesh... page with textbox update , if delete click then that row also delete from
delete data from database - SQL
delete data from database  HOw to delete specific data from table> I want to delete one record from database. Thnx  Hi friend, -------------------------------------------- Visit for more information
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
how to delete a jar file from mobile by using j2me program.
how to delete a jar file from mobile by using j2me program.  When i'll update a new version jar in mobile. Then i want to delete that old jar which is previously present in mobile. How to do
Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads