Once we run the program, the HTTP server will start locally listening on port 8080.
Next, executing a DELETE request from the command line to delete an employee with the name as bar will give you the number of records deleted from the database:
$ curl -X DELETE http://localhost:8080/employee/delete?name\=barNumber of rows deleted in database are :: 1
Let’s look at the program we have written:
- We defined a deleteRecord handler, which gets the name to be deleted from the database as the request variable, prepares a DELETE statement with a name as a placeholder, which will be replaced dynamically, executes the statement, gets the count of rows deleted as a result of its execution, and writes it to an HTTP response stream.