cURL – DELETE request examples

To send a DELETE request, uses cURL -X DELETE Terminal $ curl -X DELETE http://localhost:8080/user/100 The above example will delete a user where user id is 100. References cURL official website cURL – POST request examples

Spring Data MongoDB : Delete document

In Spring data for MongoDB, you can use remove() and findAndRemove() to delete documents from MongoDB. remove() – delete single or multiple documents. findAndRemove() – delete single document, and returns the deleted document. Common Mistake Don’t use findAndRemove() to perform a batch delete (remove multiple documents), only the first document that matches the query will …

Read more

Java MongoDB : Delete document

In this tutorial, we show you how to use collection.remove() to delete documents from the collection. 1. Test Data Insert 10 documents from number 1 to 10 for testing. for (int i=1; i <= 10; i++) { collection.insert(new BasicDBObject().append("number", i)); } 2. DBCollection.remove() See below code snippets to delete documents. Example 1 Get first document …

Read more

Oracle Stored Procedure DELETE example

Here’s a DELETE stored procedure example in Oracle database. 1. Table SQL Script DBUSER table creation script. CREATE TABLE DBUSER ( USER_ID NUMBER (5) NOT NULL, USERNAME VARCHAR2 (20) NOT NULL, CREATED_BY VARCHAR2 (20) NOT NULL, CREATED_DATE DATE NOT NULL, PRIMARY KEY ( USER_ID ) ) 2. Stored Procedure A stored procedure, delete the record …

Read more

JDBC PreparedStatement – Delete a row

A JDBC PreparedStatement example to delete a row. RowDelete.java package com.mkyong.jdbc.preparestatement.row; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; public class RowDelete { private static final String SQL_DELETE = "DELETE FROM EMPLOYEE WHERE NAME=?"; public static void main(String[] args) { try (Connection conn = DriverManager.getConnection( "jdbc:postgresql://127.0.0.1:5432/test", "postgres", "password"); PreparedStatement preparedStatement = conn.prepareStatement(SQL_DELETE)) { preparedStatement.setString(1, "mkyong"); …

Read more

JDBC Statement – Delete a row

A JDBC Statement example to delete a row. RowDelete.java package com.mkyong.jdbc.statement.row; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class RowDelete { public static void main(String[] args) { try (Connection conn = DriverManager.getConnection( "jdbc:postgresql://127.0.0.1:5432/test", "postgres", "password"); Statement statement = conn.createStatement()) { int row = statement.executeUpdate(deleteByName("mkyong")); // rows affected System.out.println(row); } catch (SQLException e) { …

Read more

How to delete row in JSF dataTable

This example is enhancing the previous JSF 2 dataTable example, by adding a “delete” function to delete the row in dataTable. Delete Concept The overall concept is quite simple : 1. Assign a “Delete” link to the end of each row. //… <h:dataTable value="#{order.orderList}" var="o"> <h:column> <f:facet name="header">Action</f:facet> <h:commandLink value="Delete" action="#{order.deleteAction(o)}" /> </h:column> 2. If …

Read more