How to delete the row from the Database by using 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());
}
}
}
View Answers
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:
Advertisements
Delete a row from database by idDelete 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 hibernatedelete 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
sqlite database delete rowsqlite
database delete row
How to
delete row from SQLite
Database?
NSString *updateSQL = [NSString stringWithFormat: @"
DELETE FROM aListDB WHERE id='%@'",details.ids
how to display a table from database using servlethow 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:ADS_TO_REPLACE_1
http://roseindia.net/jsp/
servlet-jsp-data
delete row using iddelete 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 JDBC ResultSet Delete Row ExampleJDBC ResultSet
Delete Row Example:
Learn
how to
delete row using ResultSet. We are also used ResultSet object
with update capability for
delete rows
from... for
delete the current
row form
the table of the ResultSet object.
Example
delete multiple row using checkboxdelete multiple
row using checkbox
delete multiple
row using... fields bookid,author and title in the
database.
1) Create book.jsp
<%@page...=null;
st=conn.createStatement();
rs = st.executeQuery("select *
from book");
int
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.... After establishing the connection we are going to
delete a specific
row
from Delete points from databaseDelete 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
fetch record from oracle database using jsp-servlet?fetch record
from oracle
database using jsp-
servlet?
how can i fetch data
from oracle
database by
using jsp-
servlet. i'm
using eclipse, tomcat server and oracle
database and creating jsp pages and also
using servlet 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 data from database - SQLdelete 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
delete rowdelete 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 Deleting Mysql Clob data using servlet Deleting Mysql Clob data
using servlet
In this Section, we will discuss about
how to
delete a Clob data
from a
database
table
using servlet. A CLOB... such as HTML. CLOB values are not stored as a part of the
row of
the
database 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... the
row having minimum ID.
statement.executeUpdate("
delete from stu_info