Coder Social home page Coder Social logo

book-db's Introduction

Book DB

Story

Flynn, local librarian, wants to digitalize his good ol' book register. Searching for records in a massive set of massive books is time consuming. Your task is to create a simple application that will store books and authors in a PostgreSQL database, and will allow Flynn to add, update, and list all entries.

What are you going to learn?

  • connect to a database using low level technology (JDBC).
  • handle edge cases and exceptions.

Tasks

  1. Create a PostgreSQL database called books and import both schema and data from books.sql file.

    • Database with name books exists
    • Tables book and author are created and filled with sample data
  2. Create a class called BookDbManager (in a subpackage called manager) with a method connect() that will link to your books database and return DataSource. Use PGSimpleDataSource to establish connection.

    • Class BookDbManager exists, and its connect() method connects to the database and returns a DataSource.
  3. Create AuthorDaoJdbc and BookDaoJdbc classes in the model subpackage. Each one of them must accept a DataSource as a constructor parameter. Instances of JDBC DAOs will be managed by BookDbManager.

    • Classes AuthorDaoJdbc and BookDaoJdbc are implemented.
    • Classes AuthorDaoJdbc and BookDaoJdbc use PreparedStatements.
    • Exceptions are chained and thrown as RuntimeExceptions, to avoid "exception swallowing".
  4. Make this app functional with a simple console UI. Implement UserInterface's methods, and call them from BookDbManager using a main menu -> submenu workflow. Make sure that the user is able to list and edit all the records, as well as add new ones.

    • Main menu with options a - Authors, b - Books and q - Quit navigates to the selected submenu and is functional
    • Resources menu with options l - List, a - Add, e - Edit and q - Quit is functional on the selected entities

General requirements

None

Hints

  • When you create a dataSource object that will be responsible for your connection to the database, remember to check whether the connection actually works. You can do it by invoking dataSource.getConnection().close();
  • Remember to keep your queries SQL-injection-proof by using java.sql.PreparedStatement

Background materials

book-db's People

Contributors

mjoe92 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.