Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java class with the following methods. Call each method in the main function and display any results to the console with descriptions. connect():

Write a Java class with the following methods. Call each method in the main function and display any results to the console with descriptions.

connect(): Connects to the cars keyspace on Cassandra. (with the example data from car_crashes.csv loaded).

getRecordCount(): Returns the number of records/tuples in the cars table. Use the COUNT() CQL aggregate function (see Cassandra Doc and the Query Builder SELECT Doc). Call this method and display the number of records.

getIntoxicationCrashes(float level): Count the number of car crashes where alcohol was greater than the given level. Call this method with the value of 3.8 and display the resulting count.

getRankOfState(String state): Determine the rank of a state in terms of number of car crashes every year. Assume that a high ranking means there are more crashes (which is bad). Note that some states may tie for a given rank. Call the method with a couple states including SC and display the result to console.

addEntry(int pk, float total, float speeding, float alcohol, float not_distracted, float no_previous, float ins_premium, float ins_losses, String abbrev): Inserts a new record/tuple into the cars table. Test this method by inserting made-up date an imaginary state with the abbreviation TL. After calling this method, call getRecordCount() again to display the new record count for cars.

disconnect(): Closes the database database session.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions

Question

Identify the different methods employed in the selection process.

Answered: 1 week ago

Question

Demonstrate the difference between ability and personality tests.

Answered: 1 week ago