Example : How to  delete record from Oracle 10g/11g using  jsp [JSP Delete Code].

<%-- 
    Document   : JSP Delete Code
    Created on : 14 May, 2019, 2:15:53 PM
    Author     : Codershelpline
--%>

//   JSP & Oracle 10g Connectivity Code
<%@page contentType="text/html; charset=utf-8" language="java" import="java.sql.*"import=
       "java.util.*" errorPage=""%>
<%
    Connection conn=null;
    PreparedStatement pst=null;
    ResultSet rs;
    Statement st=null;
	
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","putusernamehere",
         "putpasswordhere");
    out.println("Database connected");

//   Code for Transfer Html data into JSP variables   
    String UrTxtEmail3=request.getParameter("UrTxtEmail1");
          
    String sub2=request.getParameter("sub");
try
    {
        if(sub2!=null)
        {
//   Code to Delete Data from Oracle 10g Database			
            if(sub2.equals("Delete"))
            {
                pst=conn.prepareStatement("delete from TABLENAME where UrTxtEmail5=
                      '"+UrTxtEmail3+"' ");
                pst.executeUpdate();
                out.println("Record Deleted successfully");                
            }
         }
     }
    catch(Exception e)
    {
        out.println(e);        
    }
%>
<!DOCTYPE html>
<html>    
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>All Integrated Code</title>
    </head>

    <body>    
        <form><center>
            <fieldset style="width: 60%; background-color: aliceblue; border-radius: 8px; border- 
                     width: 4px; border-color: cadetblue">                
                <table>
                   <h1>User Registration Page</h1>
                   <hr style="width: 90%">
                
                    <tr>
                        <td>User Name</td>
                        <td>:</td>
                        <td>
                            <input type="text" name="UrTxtUname1" id="UrTxtUname2" placeholder="Enter 
                                 User ID">
                        </td>                        
                     </tr>

                     <tr>
                         <td>Password</td>
                         <td>:</td>
                         <td>
                            <input type="password" name="UrPassPsd1" id="UrPassPsd2" 
                                 placeholder="Enter Password">
                         </td>
                      </tr>
                    
                    <tr>
                        <td>Date of Birth</td>
                        <td>:</td>
                        <td>
                            <input type="date" name="UrDateDob1" id="UrDateDob2">
                        </td>
                    </tr>

                    <tr>
                        <td>Gender</td>
                        <td>: </td>
                        <td>
                            <input type="radio" name="UrRdbGender1" id="UrRdbGenderM2" value="Male" 
                                 >Male 
                            <input type="radio" name="UrRdbGender1" id="UrRdbGenderF2" value="Female" 
                                 >Female 
                        </td>
                    </tr>
                    
                    <tr>
                        <td>Mobile No.</td>
                        <td>:</td>
                        <td>
                            <input type="number" name="UrNumMob1" id="UrNumMob2" placeholder="Enter 
                                 10 digit No.">
                        </td>
                    </tr>

                    <tr>
                        <td>E-mail</td>
                        <td>:</td>
                        <td>
                            <input type="Email" name="UrTxtEmail1" id="UrTxtEmail2" 
                                 placeholder="[email protected]">
                        </td>
                    </tr>

                    <tr>
                        <td>Qualification Details</td>
                        <td>:</td>
                        <td>
                            <input type="checkbox" name="UrChkMatric1" id="UrChkMatric2" 
                                  value="Matric">Matric
                            <input type="checkbox" name="UrChkInter1" id="UrChkInter2" 
                                  value="Intermediate">Intermediate
                            <input type="checkbox" name="UrChkGrad1" id="UrChkGrad2" 
                                  value="Graduation">Graduation
                        </td>
                    </tr>
                    
                    <tr>
                        <td>Address</td>
                        <td>:</td>
                        <td>
                            <textarea rows=10 cols=15 name="UrTxrAddr1" id="UrTxrAdd2"></textarea>
                        </td>
                    </tr>

                    <tr>
                        <td>State</td>
                        <td>:</td>
                        <td>
                            <select name="UrCmbState1" id="UrCmbState2">
                                <option value="Select One">Select One</option>
                                <option value="Bihar">Bihar</option>
                                <option value="Uttar Pradesh">Uttar Pradesh</option>
                            </select>
                        </td>
                    </tr>
                    
                    <tr>
                        <td></td>
                        <td></td>
                        <td>
                            <input type="submit" name="sub" id="subSubmit2" value="Submit">
                            <input type="reset" name="sub" id="subReset2" value="Reset">                            
                            <input type="submit" name="sub" id="subDelete2" value="Delete">                
                        </td>
                    </tr>
                </table>
             </fieldset>
          </center>
      </form>
    </body>
</html>

Loading

Categories: JSP

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.