Answered step by step
Verified Expert Solution
Question
1 Approved Answer
DDL: https://www.eecs.yorku.ca/~papaggel/courses/eecs3421/docs/assignments/a2/a2.ddl SQL https://www.eecs.yorku.ca/~papaggel/courses/eecs3421/docs/assignments/a2/a2.sql you will create the class Assignment2.java which will allow you to process queries using JDBC. We will use the standard tables
DDL:
https://www.eecs.yorku.ca/~papaggel/courses/eecs3421/docs/assignments/a2/a2.ddl
SQL
https://www.eecs.yorku.ca/~papaggel/courses/eecs3421/docs/assignments/a2/a2.sql
you will create the class Assignment2.java which will allow you to process queries using JDBC. We will use the standard tables provided in the a2.ddl for this assignment. If you feel you need an intermediate view to execute a query in a method, you must create it inside that method. You must also drop it before exiting that method. Rules: . Standard input and output must not be used. This will halt the "automarker and you will probably end up with a zero. The database, username, and password must be passed as parameters, never "hard-coded .Be sure to close all unused statements and result sets. All return values will be String, boolean or int values. A successful action (Update, Delete) is when o It doesn't throw an SQL exception, and o The number of rows to be updated or deleted is correct Class name Assignment2.java Allows several interactions with a postgreSQL database. Instance Variables Type Connection y want to add more) Description The database connection for this session. Methods (y Constructor t20 want to add helper methods. Identifies the L driver using Class forName method Method boolean connectDB(String Using the String input parameters which are the URL, username, and possword URL, String username, String respectively, establish the Connection to be used for this session. Returns true if password) the connection was successful. Closes the connection. Returns true if the closure was successful boolear Inserts a row into the country table. cid is the name of the country, name is the name of the country, height is the highest elevation point and population is the population of the newly inserted country. You have to check if the country with id cid exists. Returns true if the insertion was successful, false otherwise. String name, int height, int Returns the number of countries in table "oceanAccess" that are located next to the ocean with id oid. Retums -1 if an error occurs. int ToOceanCount(int String Returns a string with information of an ocean with id oid. The output should be formatted as "oid:oname:depth. Returns an empty string if the ocean does not exist. EECS3421, M Section, Introduction to Databases Assignment 2 Metho Description Changes the HDI value of the country cid for the year year to the HDI value chgHDl(int cid, int year, flt supplied (newHDI). Returns true if the change was successful, false otherwise. boolean deleteNeighbour(int clid, c2id) Deletes the neighboring relation between two countries. Returns true if the deletion was successful, false otherwise. You can assume that the neighboring relation to be deleted exists in the database. Remember that if c2 is a neighbor of cl, c1 is also a neighbour of c2. String listCountryLanguages int cid) The list of languages should follow the contiguous format described below, and Returns a string with all the languages that are spoken in the country with id cid contain the following attributes in the order shown: (NOTE: before creating the string order your results by population). 1id: 1Iname:l1population l2id:12Iname:12populationIn. where: . . . lid is the id of the language. Iname is name of the country population is the number of people in a country that speak the language, note that you will need to compute this number, as it is not readily available in the database. Returns an empty string if the country does not exist. updateHeight(int cid, int decrH) Decreases the height of the country with id cid. This decrease might happen due to the natural erosion i.e. height decrH). Returns true if the update was successful, false otherwise. boolean updateDBO Create a table containing all the countries which have a population over 100 million. The name of the table should be mostPopulousCountries and the attributes should be cid INTEGER (country id) cname VARCHAR(20) (country name) . . Returns true if the database was successfully updated, false otherwise. Store the results in ASC order according to the country id (cid). you will create the class Assignment2.java which will allow you to process queries using JDBC. We will use the standard tables provided in the a2.ddl for this assignment. If you feel you need an intermediate view to execute a query in a method, you must create it inside that method. You must also drop it before exiting that method. Rules: . Standard input and output must not be used. This will halt the "automarker and you will probably end up with a zero. The database, username, and password must be passed as parameters, never "hard-coded .Be sure to close all unused statements and result sets. All return values will be String, boolean or int values. A successful action (Update, Delete) is when o It doesn't throw an SQL exception, and o The number of rows to be updated or deleted is correct Class name Assignment2.java Allows several interactions with a postgreSQL database. Instance Variables Type Connection y want to add more) Description The database connection for this session. Methods (y Constructor t20 want to add helper methods. Identifies the L driver using Class forName method Method boolean connectDB(String Using the String input parameters which are the URL, username, and possword URL, String username, String respectively, establish the Connection to be used for this session. Returns true if password) the connection was successful. Closes the connection. Returns true if the closure was successful boolear Inserts a row into the country table. cid is the name of the country, name is the name of the country, height is the highest elevation point and population is the population of the newly inserted country. You have to check if the country with id cid exists. Returns true if the insertion was successful, false otherwise. String name, int height, int Returns the number of countries in table "oceanAccess" that are located next to the ocean with id oid. Retums -1 if an error occurs. int ToOceanCount(int String Returns a string with information of an ocean with id oid. The output should be formatted as "oid:oname:depth. Returns an empty string if the ocean does not exist. EECS3421, M Section, Introduction to Databases Assignment 2 Metho Description Changes the HDI value of the country cid for the year year to the HDI value chgHDl(int cid, int year, flt supplied (newHDI). Returns true if the change was successful, false otherwise. boolean deleteNeighbour(int clid, c2id) Deletes the neighboring relation between two countries. Returns true if the deletion was successful, false otherwise. You can assume that the neighboring relation to be deleted exists in the database. Remember that if c2 is a neighbor of cl, c1 is also a neighbour of c2. String listCountryLanguages int cid) The list of languages should follow the contiguous format described below, and Returns a string with all the languages that are spoken in the country with id cid contain the following attributes in the order shown: (NOTE: before creating the string order your results by population). 1id: 1Iname:l1population l2id:12Iname:12populationIn. where: . . . lid is the id of the language. Iname is name of the country population is the number of people in a country that speak the language, note that you will need to compute this number, as it is not readily available in the database. Returns an empty string if the country does not exist. updateHeight(int cid, int decrH) Decreases the height of the country with id cid. This decrease might happen due to the natural erosion i.e. height decrH). Returns true if the update was successful, false otherwise. boolean updateDBO Create a table containing all the countries which have a population over 100 million. The name of the table should be mostPopulousCountries and the attributes should be cid INTEGER (country id) cname VARCHAR(20) (country name) . . Returns true if the database was successfully updated, false otherwise. Store the results in ASC order according to the country id (cid)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started