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 tables;
private Database data;
public Database() {
setTables(new VolatileHashMap());
public HashMap getTables() {
return tables;
}
public void setTables(HashMap tables) {
this.tables = tables;
}
@SuppressWarnings("unchecked")
public List interpret(String query) {
Object nullResponse = "Failure: Query was unrecognized.";
List responseList = new LinkedList();
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) nullResponse;
}
}
}
return responseList;
@Override //do not change
public void close() throws IOException {
}
}
DROP TABLE table_name > > > The table_name is any valid name belonging to a table that already exists in the database. The query should remove the stored table with the given name from the database if it exists. In a successful response, explain the name of the dropped table and how many rows it had, and return the removed table. In a failed response, explain an appropriate explanation of the failure, and do not return any table. SHOW TABLES _tables table name* row_count The query should always succeed, because it an accessor with no edge cases. In a successful response, explain how many tables are in the database, and return a computed table named _tables with a primary string column table_name and an integer column row_count such that the rows list all the table names in the database with their respective row counts. > The row counts for tables are always 0 in this module, but in later modules tables can have any number of rows, so evaluate the row counts without hard-coding them. If there are no tables in the database, there is still a computed table, but it contains no rows. Refer to the table to the right for an example of a computed table for a hypothetical database. "abc" 17 "wxyz" > If th "pq DROP TABLE table_name > > > The table_name is any valid name belonging to a table that already exists in the database. The query should remove the stored table with the given name from the database if it exists. In a successful response, explain the name of the dropped table and how many rows it had, and return the removed table. In a failed response, explain an appropriate explanation of the failure, and do not return any table. SHOW TABLES _tables table name* row_count The query should always succeed, because it an accessor with no edge cases. In a successful response, explain how many tables are in the database, and return a computed table named _tables with a primary string column table_name and an integer column row_count such that the rows list all the table names in the database with their respective row counts. > The row counts for tables are always 0 in this module, but in later modules tables can have any number of rows, so evaluate the row counts without hard-coding them. If there are no tables in the database, there is still a computed table, but it contains no rows. Refer to the table to the right for an example of a computed table for a hypothetical database. "abc" 17 "wxyz" > If th "p