1. Homepage
  2. Programming
  3. Full Stack Application Development Assignment 3: TCP-based networking multi-threaded client-server application

Full Stack Application Development Assignment 3: TCP-based networking multi-threaded client-server application

Engage in a Conversation
BirminghamFull Stack Application DevelopmentTCPClient Server ApplicationJavaJDBC

Assignment 3 - Full Stack CourseNana.COM

Contents CourseNana.COM

  1. 1  Abouttheassignment ...................... 1 CourseNana.COM

  2. 2  Problemstatement........................ 2 CourseNana.COM

  3. 3  Settingupthedatabase ..................... 3 CourseNana.COM

  4. 4  Templates............................. 3 CourseNana.COM

  5. 5  Methodsdescription ....................... 4 CourseNana.COM

  1. 5.1  Credentials.java.......................... 4 CourseNana.COM

  2. 5.2  RecordsDatabaseServer.java................... 4 CourseNana.COM

  3. 5.3  RecordsDatabaseService.java .................. 4 CourseNana.COM

  4. 5.4  RecordsDatabaseClient.java ................... 5 CourseNana.COM

  1. 6  Whattosubmit?......................... 7 CourseNana.COM

  2. 7  Rubric............................... 8 CourseNana.COM

  3. 8  Sampleoutputs.......................... 8 CourseNana.COM

  1. 8.1  Serveroutput........................... 8 CourseNana.COM

  2. 8.2  Clientoutput ........................... 8 CourseNana.COM

1 About the assignment CourseNana.COM

2 Problem statement 2 CourseNana.COM

Note: As this assignment is being released a few days before the Week 10 lectures on JDBC, you have been given a long submission deadline in order to give you plenty of time to get familiar with the concepts. CourseNana.COM

2 Problem statement CourseNana.COM

In this assignment you will be implementing a complete full stack application by “putting together” all the bits and pieces you have been studying over the course. The emphasis though is on JDBC and Java networking aspects, as the rest has been assessed in previous assignments. CourseNana.COM

In particular, you will be developing a 3-tier TCP-based networking multi-threaded client-server application to consult a database about vinyl records. The application features a client that offers a JavaFX based graph- ical user interface to request the service and communicate with a intermedi- ate server providing a query specific service. The server, located in the local host, will be composed of two parts or classes; one being the main server which attend request as they arrive on an infinite loop, and the server’s service provider that are created to attend each service. It is the server’s service provider which does connects to the database using JDBC, retrieves the outcome of the query and sends back the outcome to the client. CourseNana.COM

Although each service provider thread will only attend 1 request and then stop, the server will attend any number of request by creating new service threads. CourseNana.COM

The service provided is a fixed but parameterizable query; Given an artist’s last name and a record shop’s city, the query must retrieve the list of records available from the author at the indicated record shop. For each record available, the query must retrieve, the record’s title, the music label, the genre and the recommended retailer’s price together with the number of copies available for that record at that record shop. Records from the artist that are not available in the record shop (i.e. 0 copies) should NOT be listed. For artists that do not have a surname, e.g ‘Metallica’, the band name should be used. In these cases, both the firstname and lastname in the database are set to the band name. CourseNana.COM

Both, the client and the server applications should be able to work with- out errors when the query returns no entries. The server will be robust to SQL injection. CourseNana.COM

In all classes, you are requested to treat exceptions in the method that first can raise them i.e. do not rely in throws clauses to deal with exceptions at a later stage. If some exceptions requires you to stop the execution of CourseNana.COM

3 Setting up the database 3 CourseNana.COM

either the servers, or the client without a correct resolution of the request, make sure that in those cases you exit the program with code 1. Exit with code 0 if program execution is correct. CourseNana.COM

Feel free to use any IDE of your choice, but tests will be carried from the command line. The back end will be implemented in postgreSQL using postgresql-42.6.0.jar driver. Tests will be run in a Linux machine. CourseNana.COM

3 Setting up the database CourseNana.COM

For this assignment you will use the ’FSAD2024 Records’ database. This is provided to you. Download the file records.sql from Canvas. Open as postgres shell window and connect with your own credentials. First, you need to find the path on your own computer where you have the file. Then import this file is as follows: CourseNana.COM

\i /path/to/database/records.sql

Once you have imported the tables, you can list them by performing the following command in PostgreSQL: CourseNana.COM

\dt CourseNana.COM

Note that this will list all of the tables you may have created in this database. Run SQL commands to view the contents of each table by doing CourseNana.COM

SELECT * FROM tablename;

replacing tablename with the name of the table you want to look at. CourseNana.COM

4 Templates CourseNana.COM

You are provided with templates for all classes in canvas. The exercise requires you to fill the gaps clearly identified with; CourseNana.COM

//TO BE COMPLETED CourseNana.COM

The templates already contain all the atributes, methods, and correct signatures. There is no need to create more attributes for the classes, nor additional methods, nor to import new classes or libraries, but you can declare local variables within the methods as you may need. Do not alter the signature of the methods as the automarker will rely on these. CourseNana.COM

5 Methods description 4 CourseNana.COM

5 Methods description CourseNana.COM

Only move to this stage when you have set up the database, as above. CourseNana.COM

5.1 Credentials.java CourseNana.COM

The Credentials.java contains the credentials for the database (username, password, url) and for the server connection (host address, port number). You must replace the credentials with your own. Submitting this class is optional, as we are going to use our own credentials for testing your code. Therefore, you can delete this class from the src folder of your .zip file before submitting your assignment. CourseNana.COM

5.2 RecordsDatabaseServer.java CourseNana.COM

The server main class. This server provides a service to access the Records database. The server application will run indefinitely until Ctrl+C (Win- dows or Linux) or Opt-Cmd-Shift-Esc (Mac OSX) is pressed. Add your student id in the file opening comments. CourseNana.COM

public RecordsDatabaseServer(): Class constructor. Creates the server socket. Reads the connection credentials from class Credentials. public void executeServiceLoop(): Runs the service (infinite) loop. This method accepts the server’s service requests. The method listens for incoming client requests and creates a service threads to attend the CourseNana.COM

requests as needed.
public static void main(String[] args): Provided. No need to do CourseNana.COM

anything. Execution.
5.3 RecordsDatabaseService.java CourseNana.COM

This class is the service provider or client handler. This class is the one responsible for reading the client request, connect to the database, make the query, retrieve the outcome of the query and sends it back to the client. We are using TCP networking, so if you have not completed the Week 9 lab exercise, it is highly recommended you do so. This class extends Thread. Add your student id in the file opening comments. CourseNana.COM

public RecordsDatabaseService(Socket aSocket): Class construc- tor. Initializes the server service’s socket attribute and launches the ser- vice thread. CourseNana.COM

5 Methods description 5 CourseNana.COM

public String[] retrieveRequest(): Receives the information corre- sponding to the client request. This method accepts the server’s service requests. Upon receiving the service request, it parses the message to remove the termination character (‘#’) from the incoming message. The message will arrive in the form of a string. The remaining part of the incoming message contains the two parameters of the query; that is, the artist’s surname and the city of the record shop separated by a semicolon; e.g. ‘Sheeran;Cardiff’. This method must parse the message splitting this message content into its two components and return a String[] with two elements; the first one being the artist’s surname and the second being the record shop. CourseNana.COM

public boolean attendRequest(): This method provides the actual service. It connects to the database, make the query, execute the query and retrieve the outcome and process the query. It should be robust to SQL injection. The connection, statement and result set should be closed properly afterwards. The processing of the query will transfer the contents of the ResultSet obtained from executing the query, into a CachedRowSet object that can survive the closing of the connection and can be sent over a socket (i.e. it requires to be serializable). The method returns a flag indicating whether the service has been attended sucessfully. Finally, to transfer the contents of the ResultSet into a CachedRowSet object you can use; CourseNana.COM

RowSetFactory aFactory = RowSetProvider.newFactory(); CachedRowSet crs = aFactory.createCachedRowSet(); crs.populate(rs); //with rs being the ResultSet CourseNana.COM

variable. CourseNana.COM

public void returnServiceOutcome(): Communicate the service out- come back to the client. This method returns the outcome of the request to the client and closes the service’s socket. To send full objects through a socket you can use ObjectOutputStream. For instance; CourseNana.COM

ObjectOutputStream outcomeStreamWriter = new ObjectOutputStream(...); CourseNana.COM

outcomeStreamWriter.writeObject(...); CourseNana.COM

6 What to submit? 7 CourseNana.COM

using ObjectInputStream; e.g. CourseNana.COM

ObjectInputStream outcomeStreamReader = new ObjectInputStream(outcomeStream); CourseNana.COM

serviceOutcome = (CachedRowSet) outcomeStreamReader.readObject(); CourseNana.COM

Upon receiving this outcome, the method iterates over outcome to update the table contents. For this, you will use the aforementioned nested class MyTableRecord, e.g. CourseNana.COM

ObservableList <MyTableRecord > tmpRecords = result.getItems(); CourseNana.COM

//Here, result is the TableView object. tmpRecords.clear(); //Clear the table content
while (this.serviceOutcome.next()) {
...
}
result.setItems(tmpRecords);
//Update table contents CourseNana.COM

  • public void execute(): This method implements the callback action to be execute when the button to request the service is pushed. In order to do so, it has to create a service request message containing the two parameters of the query by reading the values at the input TextFields; that is, the author’s surname and the city of the library separated by a semicolon; e.g. ‘Sheeran;Cardiff’, and save this into the userCommand attribute. This method will then further proceed to initialize the socket, request the service and report the service outcome by calling the appro- priate methods. Finally, it closes the connection with the server’s socket. CourseNana.COM

  • public void start(Stage primaryStage): Provided. No need to do anything. This is JavaFX’s main method. This method creates the GUI. CourseNana.COM

  • public static void main (String[] args): Provided. No need to do anything. This is the overall main method. It launches the client appli- CourseNana.COM

    cation. CourseNana.COM

6 What to submit? CourseNana.COM

This is a sumative assignment. CourseNana.COM

  1. Compress into a single .zip file the three .java files corresponding to RecordsDatabaseServer.java, RecordsDatabaseService.java and the RecordsDatabaseClient.java classes. You may or may not include the Credentials.java file. CourseNana.COM

  2. Submit the .zip file into canvas. CourseNana.COM

7 Rubric 8 CourseNana.COM

Do NOT include the database file .sql or the postgres driver in the .zip. CourseNana.COM

 IMPORTANT: Do NOT use winrar for compressing but standard .zip. Do ONLY zipped the afore mentioned files. Do NOT create or organize the files into folders. If you develop your code in some IDE, e.g. IntelliJ, extract only the source files and do not submit the whole project. A penalty will be applied to your marks if any repackaging is necessary at our end. CourseNana.COM

7 Rubric CourseNana.COM

RecordsDatabaseServer.java: 25% RecordsDatabaseService.java: 40% RecordsDatabaseClient.java: 35% CourseNana.COM

8 Sample outputs CourseNana.COM

Your outputs should match the sample outputs. CourseNana.COM

8.1 Server output CourseNana.COM

All server output is reported via the console. This combines the output of
both the
RecordsDatabaseServer.java and the RecordsDatabaseService.java as they together both form the server application. An exemplary output of
the server application is shown in Figure 2. The numbers accompanying the “Service thread” line prefixes corresponds to the thread id. These will vary
in each run.
CourseNana.COM

8.2 Client output CourseNana.COM

The client output is reported via both, the GUI and the console. An exem- plary output of the client application in the console is shown in Figure 3. The corresponding two services requests in such execution are presented in Figures 4 and 5 respectively. Also, Figure 1 shows how the output table should look when a query returns no records. A console output when a query returns no records will simply be empty e.g. CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Birmingham代写,Full Stack Application Development代写,TCP代写,Client Server Application代写,Java代写,JDBC代写,Birmingham代编,Full Stack Application Development代编,TCP代编,Client Server Application代编,Java代编,JDBC代编,Birmingham代考,Full Stack Application Development代考,TCP代考,Client Server Application代考,Java代考,JDBC代考,Birminghamhelp,Full Stack Application Developmenthelp,TCPhelp,Client Server Applicationhelp,Javahelp,JDBChelp,Birmingham作业代写,Full Stack Application Development作业代写,TCP作业代写,Client Server Application作业代写,Java作业代写,JDBC作业代写,Birmingham编程代写,Full Stack Application Development编程代写,TCP编程代写,Client Server Application编程代写,Java编程代写,JDBC编程代写,Birminghamprogramming help,Full Stack Application Developmentprogramming help,TCPprogramming help,Client Server Applicationprogramming help,Javaprogramming help,JDBCprogramming help,Birminghamassignment help,Full Stack Application Developmentassignment help,TCPassignment help,Client Server Applicationassignment help,Javaassignment help,JDBCassignment help,Birminghamsolution,Full Stack Application Developmentsolution,TCPsolution,Client Server Applicationsolution,Javasolution,JDBCsolution,