Question: In this task you must operate on the original state of a sample benchmark TPC-HR database. It is explained at the end of Prologue section

In this task you must operate on the original state of a sample benchmark TPC-HR database. It is explained at the end of Prologue section how to return to the original state of the database. Consider implementation of JDBC application in a file task4.java. Your task is to improve performance of the application. Implement JDBC application with the same functionality as an application included in a file task4.java and save it in a file solution4.java. Use Linux command time to measure time spend on processing of the application before and after the improvements in the following way. time java task4 time java solution4 Explain in the comments attached at the end of a file solution4.java why the original application was slower than the improved one and include the results from testing with time command. Deliverables A file solution4.java with the improved application, with the explanations why the original application was slower than the improved one and with the results from testing with time command.

task4

import java.sql.*; class task4 { public static void main (String args []) throws SQLException, ClassNotFoundException { // Load the Oracle JDBC driver Class.forName ("oracle.jdbc.driver.OracleDriver"); Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:db", "tpchr", "oracle"); try{ System.out.println( "Connected to a database server" ); System.out.println( ); double price = 0.0; long counter = 0; Statement stmt1 = conn.createStatement(); ResultSet rset1 = stmt1.executeQuery( "SELECT * FROM LINEITEM" ); while ( rset1.next() ) { price = rset1.getDouble(6); if (price == 2644.76) counter++; } System.out.println( "2644.76" + " " + counter ); counter = 0; Statement stmt2 = conn.createStatement(); ResultSet rset2 = stmt2.executeQuery( "SELECT * FROM LINEITEM" ); while ( rset2.next() ) { price = rset2.getDouble(6); if (price == 6118.28) counter++; } System.out.println( "6118.28" + " " + counter ); counter = 0; Statement stmt3 = conn.createStatement(); ResultSet rset3 = stmt3.executeQuery( "SELECT * FROM LINEITEM" ); while ( rset3.next() ) { price = rset3.getDouble(6); if (price == 29461.4) counter++; } System.out.println( "29461.4" + " " + counter ); System.out.println( "Done." ); } catch (SQLException e ) { String errmsg = e.getMessage(); System.out.println( errmsg ); } } }

Step by Step Solution

3.46 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the improved version of the JDBC application in solution4java along with comments explaining why its faster java import javasql class solution4 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!