Simple Java project with Driver method and DAO.
$ sudo apt install mysql-server
$ mysql -p
Once you have the MySQL CLI open enter the following line to create a new user:
CREATE USER 'sqluser'@'localhost' IDENTIFIED BY 'sqluserpw';
If you receive an error, try dropping the user in case it already exists:
DROP USER 'sqluser'@'localhost';
CREATE DATABASE feedback;
USE feedback;
If you attempt to run this repository's Main.java file, you will likely receive an error stating that the 'sqluser' database user does not have permissions. Enter the following lines in the MySQL CLI:
GRANT USAGE ON *.* TO sqluser@localhost;
GRANT ALL PRIVILEGES ON feedback.* TO sqluser@localhost;
- Make sure you have the Java JDK installed.
- If you are having issues running this repository in Visual Studio Code, follow the steps provided in this article.
Modify initializeDatabase() to create a new table that isn't Comments. This could be Warleader, Student, or whatever you come up with; might as well just put it in the feedback database.
Navigate to your Desktop, and checkout the NYT's Covid dataset with:
git clone https://github.com/nytimes/covid-19-data.git
Pick one of the csv files in that repository and print it out with printFileToConsole(). The base-level files us.csv and us-states.csv will be the easiest to work with; us-counties.csv, mask-use and excess-deaths will be more complicated, but maybe let you ask more interesting questions at the end of this project.
Modify initializeDatabase() again, or create a new method that creates a database with columns matching your chosen csv file.
Instead of just printing, write a method to parse a comma-separated file into its constituent values. Hint: String split is a thing, and someString.split(",") is a valid usage.
Use prepared statements to write the data in your csv file to the database that you created.
Query your database: How many new cases of Covid were reported on March 14, 2020? How many excess deaths in Ada county, in the two weeks after the bars reopened? How has the number of mask-wearers (i.e. people who reported that they "Frequantly" or "Always" wear a mask in public when they expect to be within 6' of another person?) changed over time?