Question
Implement new drivers to support the following queries according to the given syntax and semantics. Outlines for programs: Drop table: package driver; import java.util.LinkedList; import
Implement new drivers to support the following queries according to the given syntax and semantics.
Outlines for programs:
Drop table:
package driver;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import core.Database;
import model.*;
import structure.*;
public class DropTable implements Driver {
@Override
public Response execute(String query, Database db) {
return null;
}
}
Show Table:
package driver;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import core.Database;
import model.*;
import structure.*;
public class ShowTable implements Driver {
@Override
public Response execute(String query, Database db) {
return null;
}
}
Database Class
import driver.*;
import model.*;
import structure.*;
import java.util.List;
import java.util.LinkedList;
import java.io.Closeable;
import java.io.IOException;
public class Database
implements Closeable
{
private Driver[] drivers;
private HashMap
private Database data;
public Database() {
setTables(new VolatileHashMap());
public HashMap
return tables;
}
public void setTables(HashMap
this.tables = tables;
}
@SuppressWarnings("unchecked")
public List
Object nullResponse = "Failure: Query was unrecognized.";
List
String[] querySplit = query.split(";");
for(String i: querySplit){
for(int j= 0; j Response results = drivers[j].execute(i,data); responseList.add(results); if(drivers[j]==null) { return (List } } } return responseList; @Override //do not change public void close() throws IOException { } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started