Assume we have an order table with the following fields Orde

Assume we have an order table with the following fields.
OrderNumber Integer
OrderName VARCHAR

Fill in the following code snippet to delete an order where the orderNumber variable has the value of the order to delete.

Integer OrderNumber = new Integer(5);
String query = \"DELETE FROM ODER WHERE OrderNumber = \'\"+ +\"\'\";
Statement statement = connection.createStatement();
int rowCount = statement.executeUpdate();

Solution

This is JAVA code for your required problem in this code I am using MYSQL DATABASE for performing Operation it’s up to you can use any DATABASE According to your requirement

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

public class JDBCODBC {

    public static void main(String[] args) {

        Connection con = null;

        Statement st = null;

        ResultSet rs;

        try {

         /* Code for creating and establishing Connection between JAVA Application and MYSQL DATABASE  

Class.forName(\"com.mysql.jdbc.Driver\");

            System.out.println (\"Driver Loaded\");

            con = DriverManager.getConnection(\"jdbc:mysql://localhost/alok?\"

                    + \"user=****&password=****\");

            con.setAutoCommit(true);

            System.out.println (\"DSN_IS_WORKING\"); ---print if the connection is properly working.

          Integer OrderNumber = new Integer (5);

            st = con.createStatement ();

            String query = \"delete from department where did=\" + OrderNumber;

            int rowCount = st.executeUpdate(query);

            System.out.println(\"Information Successfully Deleted\");

            System.out.println (\"Total number of record is deleted\" + rowCount);

             con.setAutoCommit(true);

            con.close();

        } catch (SQLException | ClassNotFoundException se) {

            System.out.println(se.toString());

        }

    }

}

Assume we have an order table with the following fields. OrderNumber Integer OrderName VARCHAR Fill in the following code snippet to delete an order where the o
Assume we have an order table with the following fields. OrderNumber Integer OrderName VARCHAR Fill in the following code snippet to delete an order where the o

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site