Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a JAVA PROGRAM that allows user to insert, delete, update(SQL statements). Allows the user to use/input select statements, from statements and where statements. Focus

Create a JAVA PROGRAM that allows user to insert, delete, update(SQL statements). Allows the user to use/input select statements, from statements and where statements.

Focus on whether the program can recognise if the user has entered a VALID or an INVALID statement. Such as Select name, From Student.

Implement functionality for EXECUTE command and EXIT command.

PLEASE STRICTLY USE THIS STARTER CODE BELOW:

package identification;

import java.io.*;

import java.util.Scanner;

public class Main

{

public static void main( String args[] )

{

Scanner input = new Scanner(System.in);

Command comm = null;

String information = "";

while(!(comm instanceof ExitCommand))

{

System.out.print(">");

information = input.nextLine();

if(information.contains(";"))

{

String command = information.substring(0,information.indexOf(";"));

comm = Parser.parse(command);

comm.execute();

information = information.substring(information.indexOf(";")+1)

}

}

}

}

CREATETABLE CLASS

package identification;

import java.sql.*;

public class CreateTable implements Command

{

private String tableName;

private String[] columnNameType;

public CreateTable(String input)

{

//parse the string to see if it is valid.

}

public void execute()

{

System.out.println("Valid Create Syntax.");

}

}

COMMAND CLASS

package identification;

public interface Command {

public void execute();

}

EXIT COMMAND

package identification;

public class ExitCommand implements Command {

public void execute()

{

System.out.println("System exiting.");

}

}

CLASS PARSER

package identification;

public class Parser

{

public static Command parse(String userInput)

{

Command result;

if(userInput.equals("exit"))

result = new ExitCommand();

else if(userInput.startsWith("create table"))

result = new CreateTable(userInput);

return result;

}

}

CAN YOU PLEASE FINISH THE CODE FOR THE CLASSES; DELETE, INSERT,UPDATE,DROP TABLE AND SELECT. AND FINISH UP ON THE STARTER CODE, IF THERE IS ANYTHING MISSING.

USE ANY VALIDATION RULES.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

Identify and discuss learning style differences across cultures

Answered: 1 week ago