In this lab you will move trivia quiz user information from Java
beans to an external Apache Derby database.
The external behavior of the application remains unchanged from the
previous lab.
This section details the new requirements.
Rename your current trivia quiz project
TriviaDatabase.
Be sure both the NetBeans project and the project folder have this name.
At a minimum, the external database must store the following information for
each user:
- Name
- Password
- Score data for each category
Although not required, you can also store quiz problem information:
- Category
- Question
- Possible answers
- Correct answer
The database must have at least three tables, related by foreign key
references.
Here is a recommended design:
If you store quiz problem information in the external database, here is
a recommended design:
Deployment requirements are of two kinds:
- Packaging the database
- Naming the data source
Your project will be evaluated by creating your database on the
grader's machine and running your application.
To facilitate this:
- You must have a folder under Source Packages
called SQL
- SQL must have a file called db-create.sql
- db-create.sql must have CREATE TABLE and INSERT
INTO commands sufficient to create and populate the tables
required by your application
Note that it is not necessary to populate the tables with
any users since the grader will do that during evaluation.
Be sure to test your
db-create.sql file by creating and connecting
to a new Derby database and successfully executing the file — this
is what the grader will do.
Since the grader will be creating a data source
called
jdbc/trivia to test your application, you must be sure to
use the following annotation when injecting the resource into your
bean:
@Resource(name = "jdbc/trivia")
private DataSource ...