Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Heres the improved version of the JDBC application in solution4java along with comments explaining why its faster java import javasql class solution4 ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions