The goal of this project is to use JDBC to create a Booksdatabase, populate it, and then execute different SQL statements to query or manipulate the Booksdatabase.
In this project, using JDBC application that access an installed RDBMS (you need to have an account), you will need to:
- Create the Booksdatabase tables as specified in the schema definition below.
- Initialize the different tables (at least 15 entries per table) appropriately: all fields cannot be null.
- Issue the following SQL statements. For queries print the results from java into your console:
-
- Select all authors from the authorstable. Order the information alphabetically by the author’s last name and first name.
-
- Select all publishers from the publisherstable.
-
- Select a specific publisher and list all books published by that publisher. Include the title, yearand ISBN number. Order the information alphabetically by title.
-
- Add new author
-
- Edit/Update the existing information about an author
-
- Add a new title for an author
-
- Add new publisher
-
- Edit/Update the existing information about a publisher
-
To run this project on your machine you need to make sure you have the MySQL JDBC driver installed. You can find the .jar file in this repo. Mac users should copy it to /Library/Java/Extensions
To make sure you setup everything correctly and the JDBC is running on your machine run the TestDatabase file from your shell.
To make things a little easier I created an API with the credentials to our database so that you don't have to do the setup yourself. The two methods in the API are as follows:
public static void connect() throws SQLException
public static void close()
As you can see you need to take care of error handeling if the connection isn't established, so make sure to wrap that method in a try catch block and only precede if the conenction was successful. Here is a little example how your code could look like to open and close connections to our database:
try {
JDBC.connect();
// Your code here
JDBC.close();
} catch (SQLException e) {
System.out.println("Connection Failed!");
e.printStackTrace();
return;
}
If you are catching other exepctions make sure to put the close statement into the finally block, but don't close connections that weren't established.
✅ Initialize repo
✅ Create database
✅ Compile demo data for tables
✅ Created tables
✅ Initialize tables with demo data Ravin
✅ Code: Query 1 Tyler
✅ Code: Query 2 Shri
✅ Code: Query 3 Shweta
✅ Code: Query 4 Shivangi
✅ Code: Query 5 Nit
✅ Code: Query 6 Tim
✅ Code: Query 7 Avani
✅ Code: Query 8 Jameson
🔲 One/two page documentation of the implementation
🔲 Print out two copies of documentation and output
🔲 Turn in during class Dec 5
- Open an issue when you start working on one of the queries
- You can work on it in a fork or branch
- Submit a PR when you finished and tested your code and want to merge
- Update the To-Do accordingly