delete

delete

how delete only one row in the database using jsp.database is mysql

View Answers

October 19, 2010 at 4:35 PM

Hi Friend,

Try the following code:

1)user.jsp:

<%@ page import="java.sql.*" %>
<html>
<head>
<script language="javascript">
function deleteRecord(id){
window.open('http://localhost:8080/examples/jsp/deleteuser.jsp?id='+id,'mywindow','width=500, height=350,toolbar=no,resizable=yes,menubar=yes');
}
</script>
</head>
<body>
<br><br>
<table border="1">
<tr><th>Emp ID</th><th>Name</th><th>Salary</th><th>Designation</th></tr>
<%
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String userName ="root";
String password="root";
int sumcount=0;
Statement st;
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from employee";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while(rs.next()){
%>
<tr><td><%=rs.getString("empid")%></td>
<td><%=rs.getString("name")%></td>
<td><%=rs.getString("salary")%></td>
<td><%=rs.getString("designation")%></td>
<td><input type="button" name="edit" value="Delete" style="background-color:red;font-weight:bold;color:#ffffff;" onclick="deleteRecord(<%=rs.getString(1)%>);" ></td>
</tr>
<%
}
%>
<%
}
catch(Exception e) {
e.printStackTrace();
}
%>
</table>
</form>
</body>
</html>

2)deleteuser.jsp:

<%@page import="java.sql.*"%>
<%
String id=request.getParameter("id");
int no=Integer.parseInt(id);
System.out.println(no);
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st = conn.createStatement();
st.executeUpdate("DELETE FROM employee WHERE empid = '"+no+"'");
out.println("Record is deleted successfully");
}
catch(Exception e){}
%>

Thanks


October 19, 2010 at 5:55 PM

sir i want to show only last stored record for another page.how can i set the codition for that sir









Related Tutorials/Questions & Answers:
DELETE
DELETE   I AM DOING IT IN MYSQL. DELETE FROM EMP WHERE SAL>(SELECT SAL FROM EMP WHERE ENAME='MILLAR') AND ENAME='ALLEN'; THIS IS GIVING THE FOLLOWING ERROR Error Code : 1093 You can't specify target table 'EMP
delete
delete  how delete only one row in the database using jsp.database...;td><input type="button" name="edit" value="Delete" style="background-color..."); Statement st = conn.createStatement(); st.executeUpdate("DELETE FROM employee
Advertisements
Delete Account
Delete Account  How to delete account
To delete post
To delete post  How can I delete my old post answer. I've posted 2 same answers by mistake
delete jsp
delete jsp  <%@ page language="java" contentType="text/html...; charset=ISO-8859-1"> <title>Delete Student</title> </head>...;/Controller"> <input type="hidden" name="page" value="delete"/> <
delete row
delete row  how to delete row using checkbox and button in php...="delete" > <table width="100%" border="1"> <tr><td>...;/table> <input type="submit" name="delete" value="delete" /> <?php
delete record
delete record  how to delete record using checkbox and button in php   We are providing you the jsp code that displays the database table...=conn.createStatement(); for(int a=0;a<10;a++){ st.executeUpdate("delete from book where
delete an entry using JavaScript
delete an entry using JavaScript  How to delete an entry using JavaScript
delete() method of hibernate
delete() method of hibernate  Define the use of delete() method of hibernate? Example
delete javascript object
delete javascript object  How to create and delete an object in JavaScript
how to delete a letter in a word?
how to delete a letter in a word?  how to delete a letter in a word? for example if i enter= roseindia, i want to delete 's', then output= roeindia
What is the Delete Statements in SQL?
What is the Delete Statements in SQL?  What is the Delete Statements in SQL?   Hi, Here is the answer,ADS_TO_REPLACE_1 Delete statement in SQL is used to delete partial/all data. Especially delete statement is useful
php delete checkbox
php delete checkbox  How can i delete the data with multiple check boxes in PHP
insert and delete a row programmatically
insert and delete a row programmatically  How to insert and delete a row programmatically ? (new feature in JDBC 2.0
delete an item from database
delete an item from database  how to delete an item from the database using jsp
uitableviewcell delete button position
uitableviewcell delete button position  uitableviewcell delete button position - how can i set? Thanks in Advance
delete app from iphone
delete app from iphone  How to delete an existing app from itunes
Hibernate criteria delete Example
Hibernate criteria delete Example  How to use the delete criteria in Hibernate? thanks
ModuleNotFoundError: No module named 'delete'
ModuleNotFoundError: No module named 'delete'  Hi, My Python... 'delete' How to remove the ModuleNotFoundError: No module named 'delete'... to install padas library. You can install delete python with following command
ModuleNotFoundError: No module named 'delete'
ModuleNotFoundError: No module named 'delete'  Hi, My Python... 'delete' How to remove the ModuleNotFoundError: No module named 'delete'... to install padas library. You can install delete python with following command
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
kind delete all clusters
kind delete all clusters  Hi, How to delete all the clusters created in my laptop through kind? Thanks   Hi, You can use the following command: kind delete clusters --all Above command will delete clusters you
gremlin delete all vertices
gremlin delete all vertices  Hi, How to delete all vertices with gremlin query? I am using JanusGraph as Graph Database server. I have to delete... is the command to delete all vertices with gremlin query? Thanks   Hi
Delete Query using HQL
Delete Query using HQL  Can we write 'AND' with 'WHERE' clause in delete query using HQL? For example: delete from table name where field1... is "delete from table where field1 = 'value1' and field2 = 'value2'.   Have
Hibernate delete example program
Hibernate delete example program  How to delete an object in Hibernate? In my program I have to write program to delete the data using Hibernate framework. I want to delete one row of data who's primary key is known to me. What
insert and delete data in database
insert and delete data in database  insert and delete data in database from servlets through JDBC   Hi Friend, Please visit the following links:ADS_TO_REPLACE_1 Insert Data Delete Data ThanksADS_TO_REPLACE_2
The DELETE Statement
The DELETE Statement       The DELETE statement is used to delete rows from a table. database will update...; DELETE FROM table_name WHERE column_name = some_value Let's
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
Hibernate delete HQL - Hibernate
Hibernate delete HQL  Hi I am trying hibernate tutorial. But delete HQL tutorial not working properly. It gives null pointer exception. Query class has method executeUpate() & not executeUpdate
delete a file - JSP-Servlet
delete a file  Correct question::::How can we delete a file which is stored in a server when read write operations for this particular file is closed.  http://www.communigate.com/CommuniGatePro/WebFiles.html
tree menu delete node
tree menu delete node  I have crated a tree menu having various sub nodes now i want to delete parent node and also want to delete sub nodes when... using url ....i have a problem when i perform a delete operation on parent node
Java delete file if exists
Java delete file if exists  Hi, Hi how to delete file if exists? I need example code of java delete file if exists. Thanks   Hi, following code can be used: String tempFile = "C:/mydir/myfile.txt"; //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... the delete button, the polygon in the webpage gets deleted as well as the polygon
Sql delete operation
Sql delete operation  Hi, I am tried to several times but i am... yyyy 95643663 update delete 2 aaaa bbbb 64645666 update delete update and delete are enclosed with html anchor element. if i
delete a file - JSP-Servlet
delete a file  How can we read a file which is stored in a server when read write operations for this particular file is closed
JPA delete query - EJB
JPA delete query  Hi, I have an entity InvoiceItems.java. I want to delete all the records from the table. What will be the JPA query to delete... to achieve this: Query query = em.createQuery("delete from InvoiceItems o
delete query problem - Hibernate
delete query problem  SessionFactory fact = new Configuration... = sess. beginTransaction(); String hql = "delete from STUDENT where name = 'mitha... system properly. STUDENT is not mapped. [delete from STUDENT where name = 'mitha
Create Delete Trigger in SQL
Create Delete Trigger in SQL       Create Delete Trigger in SQL fire this trigger before the DELETE operation is executed. Understand with ExampleADS
Use of delete() method in hibernate.
Use of delete() method in hibernate.  Define the use of delete() method of hibernate?   Hibernate provide the facility to delete one row... department0_ where department0_.id=? Hibernate: delete from department where id
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...: delete [delete from pkg2.Insurance insurance where id = 2
uitableview manually delete row
uitableview manually delete row  uitableview manually delete row   NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet]; [array removeObjectAtIndex:indexPath.row]; if(![array count]) [indexes addIndex
Delete a Records in Database
Delete a Records in Database       The Delete Statement is used to delete the records and rows from the table. The generalized Syntax  used for delete query in database
What does the delete operator do?
What does the delete operator do?  What does the delete operator do
What does the delete operator do?
What does the delete operator do?  What does the delete operator do
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 HQL query - Hibernate
Delete HQL query  Hi I am trying hibernate tutorial. But delete HQL tutorial not working properly. It gives null pointer exception. Query class has method executeUpate() & not executeUpdate(); log4j:WARN No appenders
Grid rows delete issue
Grid rows delete issue  I have a grid having rows with Remove button to remove rows,But we also havae an facility to remove those rows on onchange event of dropdown also,so if we delete middle row and then remove all rows
hibernate delete query :
hibernate delete query :   Hi, I m using Hibernate 3 + javadb my... NOT NULL , ITEM_ID INTEGER NOT NULL ) I want to delete a row from table...(); org.hibernate.Transaction tx = session.beginTransaction(); String query1 = "delete from

Ads