bartleby

Videos

Textbook Question
Book Icon
Chapter 15, Problem 5PC

Population Database

Make sure you have downloaded the hook’s source code from the companion Web site at www.pearson.com/gaddis. In this chapter’s source code folder you will find a program named CreateCityDB.java. Compile and run the program. The program will create a Java

DB or Apache Derby database named CityDB. The CityDB database will have a table named City, with the following columns:

Column Name Data Type
CityName CHAR (50)
Primary key  
Population DOUBLE

The CityName column stores the name of a city and the Population column stores the population of that city. After you run the CreateCityDB.java program, the City table will contain 20 rows with various cities and their populations.

Next, write a program that connects to the CityDB database, and allows the user to select any of the following operations:

  • Sort the list of cities by population, in ascending order.
  • Sort the list of cities by population, in descending order.
  • Sort the list of cities by name.
  • Get the total population of all the cities.
  • Get the average population of all the cities.
  • Get the highest population.
  • Get the lowest population.
Blurred answer
Students have asked these similar questions
5.9 LAB - Database programming with Java (SQLite)   Complete the Java program to create a Horse table, insert one row, and display the row. The main program calls four methods: createConnection() creates a connection to the database. createTable() creates the Horse table. insertHorse() inserts one row into Horse. selectAllHorses() outputs all Horse rows. Complete all four methods. Method parameters are described in the template. Do not modify the main program. The Horse table should have five columns, with the following names, data types, constraints, and values: Name Data type Constraints Value Id integer primary key, not null 1 Name text   'Babe' Breed text   'Quarter horse' Height double   15.3 BirthDate text   '2015-02-10' The program output should be: All horses: (1, 'Babe', 'Quarter Horse', 15.3, '2015-02-10') This lab uses the SQLite database rather than MySQL. Both SQLite and MySQL Connector/J implement the JDBC API. Consequently, the API is as…
5.9 LAB - Database programming with Java (SQLite)   Complete the Java program to create a Horse table, insert one row, and display the row. The main program calls four methods: createConnection() creates a connection to the database. createTable() creates the Horse table. insertHorse() inserts one row into Horse. selectAllHorses() outputs all Horse rows. Complete all four methods. Method parameters are described in the template. Do not modify the main program. The Horse table should have five columns, with the following names, data types, constraints, and values: Name Data type Constraints Value Id integer primary key, not null 1 Name text   'Babe' Breed text   'Quarter horse' Height double   15.3 BirthDate text   '2015-02-10' The program output should be: All horses: (1, 'Babe', 'Quarter Horse', 15.3, '2015-02-10') This lab uses the SQLite database rather than MySQL. Both SQLite and MySQL Connector/J implement the JDBC API. Consequently, the API is as…
Population Database   Compile and run CreateCityDB.java which will create a Java DB database named CityDB. The CityDB database will have a table named City, with the following columns: CityName & Population. Their Data Types: CHAR(50) Primary Key & DOUBLE. The CityName column stores the name of a city, and the Population column stores the population of that city. After you run the CreateCityDB.java program, the City table will contain 20 rows with various cities and their populations. Next, create an application that connects to the CityDB database and allows the user to select any of the following operations: Sort the list of cities by population, in ascending order. Sort the list of cities by population, in descending order. Sort the list of cities by name. Get the total population of all the cities. Get the average population of all the cities. Get the highest population. Get the lowest population.   CreateCityDB.java import java.sql.*; /**  This program creates the CityDB…

Chapter 15 Solutions

Starting Out with Java: Early Objects Plus MyLab Programming with Pearson eText -- Access Card Package (6th Edition)

Ch. 15.3 - Prob. 15.11CPCh. 15.3 - Prob. 15.12CPCh. 15.3 - Prob. 15.13CPCh. 15.3 - Prob. 15.14CPCh. 15.3 - What is the purpose of the % symbol in a character...Ch. 15.3 - How can you sort the results of a SELECT statement...Ch. 15.3 - Assume that the following declarations exist:...Ch. 15.3 - How do you submit a SELECT statement to the DBMS?Ch. 15.3 - Prob. 15.19CPCh. 15.3 - Prob. 15.20CPCh. 15.4 - Prob. 15.21CPCh. 15.4 - Prob. 15.22CPCh. 15.5 - The Midnight Coffee Roastery is running a special...Ch. 15.5 - Prob. 15.24CPCh. 15.6 - Prob. 15.25CPCh. 15.6 - Write a statement to delete the Book table you...Ch. 15 - Prob. 1MCCh. 15 - This is a standard language for working with...Ch. 15 - Prob. 3MCCh. 15 - The data that is stored in a row is divided...Ch. 15 - Prob. 5MCCh. 15 - This type of SQL statement is used to retrieve...Ch. 15 - This contains the results of an SQL SELECT...Ch. 15 - This clause allows you to specify search criteria...Ch. 15 - Prob. 9MCCh. 15 - Prob. 10MCCh. 15 - Prob. 11MCCh. 15 - Prob. 12MCCh. 15 - This method is specified in the Statement...Ch. 15 - This SQL statement is used to insert rows into a...Ch. 15 - This SQL statement is used to remove rows from a...Ch. 15 - Prob. 16MCCh. 15 - Prob. 17MCCh. 15 - True/False: Java comes with its own built-in DBMS.Ch. 15 - True/False: A Java programmer that uses a DBMS to...Ch. 15 - True/False: You use SQL instead of Java to write...Ch. 15 - True/False: In SQL, the not-equal-to operator is...Ch. 15 - Prob. 22TFCh. 15 - Prob. 23TFCh. 15 - Prob. 24TFCh. 15 - Prob. 1FTECh. 15 - Prob. 2FTECh. 15 - Prob. 3FTECh. 15 - What SQL data types correspond with the following...Ch. 15 - Look at the following SQL statement. SELECT Name...Ch. 15 - Write a SELECT statement that will return all of...Ch. 15 - Write a SELECT statement that will return the...Ch. 15 - Prob. 5AWCh. 15 - Write a SELECT statement that will return the...Ch. 15 - Write a SELECT statement that will return all of...Ch. 15 - Write a SELECT statement that will return the...Ch. 15 - Write a SELECT statement that will return the...Ch. 15 - Prob. 10AWCh. 15 - Write an SQL statement that does the following:...Ch. 15 - Prob. 12AWCh. 15 - Prob. 13AWCh. 15 - Assuming that conn references a valid Connection...Ch. 15 - Look at the following declaration. String sql =...Ch. 15 - Prob. 16AWCh. 15 - Prob. 17AWCh. 15 - Prob. 18AWCh. 15 - Prob. 1SACh. 15 - Prob. 2SACh. 15 - Prob. 3SACh. 15 - What is a primary key?Ch. 15 - Prob. 5SACh. 15 - What are the relational operators in SQL for the...Ch. 15 - What is the number of the first row in a table?...Ch. 15 - Prob. 8SACh. 15 - Prob. 9SACh. 15 - Customer Inserter Write an application that...Ch. 15 - Customer Updater Write an application that...Ch. 15 - Unpaid Order Sum Write an application that...Ch. 15 - Population Database Make sure you have downloaded...Ch. 15 - Personnel Database Creator Write an application...Ch. 15 - Employee Inserter Write a GUI application that...Ch. 15 - Employee Updater Write a GUI application that...
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
How to Design DB Tables for any Application? (The Basics); Author: Studytonight;https://www.youtube.com/watch?v=XUdNVaSikqY;License: Standard YouTube License, CC-BY
Create a Table (Introduction to Oracle SQL); Author: Database Star;https://www.youtube.com/watch?v=BiV1IrzB1sY;License: Standard Youtube License