Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assignment: You will implement a system that indexes and provides search feature

ID: 3761414 • Letter: A

Question

Assignment:

You will implement a system that indexes and provides search features for a file of player records, as described above. Your system will support these operations:

* Importing new records into a database file of player records.
* Retrieving the player record that matches a given PlayerID.
* Retrieving all player records that match a given player name (first and last). * Deleting the player record that matches a given PlayerID.

See the section Command File for details.
You will implement a single Java program to perform all system functions.

Input and Output:

The program will take the names of three files from the command line, like this:

java mlb <db-filename> <command script file name>

The name of the program is mbl.
<db-filename> is the name of the database input file. <command script file name> is the command script file.

Upon execution, your program will try to read player information from the database file (simple text file) and store each player’s info in a linked-list.
After importing player records into a data structure, your program will read a list of commands from the command script file and execute the commands.

Command File:

The execution of the program will be driven by a script file. Lines beginning with a semicolon character (';') are comments and should be ignored. Each non-comment line of the command file will specify one of the commands described below. Each line consists of a sequence of tokens, which will be separated by single tab characters. A newline character will immediately follow the final token on each line. The command file is guaranteed to conform to this specification, so you do not need to worry about error- checking when reading it. The following commands must be supported:

identify_by_name<tab><first name><tab><last name><newline>
Print all the PlayerID values for records in the database file that match the specified name; print an

informative message if no matches are found.

show_stats_for<tab><PlayerID><newline>
Print all the data fields in the unique player record in the database file that matches the given <PlayerID>. The display should be well-formatted and clearly labeled. If no matching record exists, print an informative message.

remove<tab><PlayerID><newline>
Update the data structure to remove the entry for this PlayerID. If no matching record exists, print an

informative message. show_playerID<newline> Print all playerIDs

Preview File Edit View Go Tools Window Help 100%-- Tue 9:53 AM a E ECHW2.pdf (page 1 of 3) Close Jaquel Macklin's Birthday Tomorrow ECHW2.pdf Snooze png over Letter MLB Player V.0.1 Intership } An index is a system used to make finding information easier. In this case, you will be given data files containing information about players in Major League Baseball and you will build in-memory index structures to support searches of records which match certain criteria. The player records will contain the following information: berry ECHW2.pdf 1 Figure 1: Player Data Fields Ethics Presentation Stuff Type/Format Comments unique identifier for this playe date of player's birth location of player's birth country of player's birth date of player's birth location of player's death country of player's death commonly-used first name for player last name for player Significance Year of birth Birth place strin -Birth country string hot Microsoft Office 11 PM Year of deathmm/dd/yy Death place Death country First name Last name Weight Height Bats Throws string strin string * Death count ng Movies hot 57 AM non-negative number approximate playing weight (pounds) non-negative numberapproximate pla approximate playing height (inches) preferred batting orientation (right or left) preferred throwing hand (right or left) date of first appearance in MLB date of last appearance in MLB R' II'L' Photos hot 19 AM * End hot question 2 ECHW2.pdf Show Allx 2015-11...15.58 AM NOV

Explanation / Answer

Hi ,

I have given the example code of your requirment below

\ I hope this would helps you

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;

public class Main {
public static void main(String[] args) throws Exception {
Connection conn = getConnection();
Statement stmt = conn.createStatement();


stmt.executeUpdate("create table survey (id int, name CHAR(5) );");

stmt.executeUpdate("INSERT INTO survey(id, name)VALUES(111, '123456789')");

ResultSet rs = stmt.executeQuery("SELECT * FROM survey");

outputResultSet(rs);

stmt.executeUpdate("drop table survey");
  
rs.close();
stmt.close();
conn.close();
}

private static void outputResultSet(ResultSet rs) throws Exception {
ResultSetMetaData rsMetaData = rs.getMetaData();
int numberOfColumns = rsMetaData.getColumnCount();
for (int i = 1; i < numberOfColumns + 1; i++) {
String columnName = rsMetaData.getColumnName(i);
System.out.print(columnName + " ");

}
System.out.println();
System.out.println("----------------------");

while (rs.next()) {
for (int i = 1; i < numberOfColumns + 1; i++) {
System.out.print(rs.getString(i) + " ");
}
System.out.println();
}

}

private static Connection getConnection() throws Exception {
Class.forName("org.hsqldb.jdbcDriver");
String url = "jdbc:hsqldb:mem:data/tutorial";

return DriverManager.getConnection(url, "sa", "");
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote