0% found this document useful (0 votes)
2 views

LabProblem1 (1)

The document outlines a lab assignment for CST 8288 focused on implementing a console application using JDBC, NetBeans IDE, and MySQL. Key requirements include using a properties file for database connection, handling exceptions with try-with-resources, and utilizing ResultSetMetaData for outputting column attributes. The application must generate a random year, query a database for matching entries, and format the output in a tabular form, with specific submission guidelines provided.

Uploaded by

vy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

LabProblem1 (1)

The document outlines a lab assignment for CST 8288 focused on implementing a console application using JDBC, NetBeans IDE, and MySQL. Key requirements include using a properties file for database connection, handling exceptions with try-with-resources, and utilizing ResultSetMetaData for outputting column attributes. The application must generate a random year, query a database for matching entries, and format the output in a tabular form, with specific submission guidelines provided.

Uploaded by

vy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CST 8288 Object Oriented Programming with Design Patterns

Lab Problem #1

Purpose Explore working with JDBC

Activity Implement a console application:

• that makes use of classes, methods and features from JDBC


• using the NetBeans IDE and MySQL
• and a database containing a partial list of recipients of The Order of Ontario
(recipients.sql)1

Coding requirements:

• Be sure to include Javadoc comments for all public classes and methods as well as comments to
explain your code.
• Your application must:
o use Properties class and a file called database.properties
(as in the Lecture examples)
▪ Be sure to place this file in the src folder … just like in the example.
▪ The connection string, userid and password should match the ones used in our
examples.
o use try-with-resources when instantiating classes that may throw exceptions,
o use ResultSetMetaData to obtain and output the column attributes:
▪ column name
▪ column type (the MySQL type) and
▪ corresponding Java class for the column.
o generate a random year between 1987 and 2020 (inclusive).
▪ Be sure to use java.security.SecureRandom
o Then search the database for all entries which match that year
(this must use a single SQL query). Be sure to:
▪ Use PreparedStatement for the SQL query

1
This example uses data from Ontario’s Data Catalogue. The full dataset is available at:
https://www.ontario.ca/page/order-ontario#section-6
▪ use ResultSet to obtain the results from the search and output the results.
▪ print an appropriate message if no matching entries can be found for that year.

Output:

o All data and metadata should be output in neatly formatted tabular form complete with
column headings. (See the sample output).

Submission:

o export your NetBeans project as a .zip


▪ name your file FirstName.Lastname.Lab1.zip
▪ name your project FirstName.Lastname.Lab1
▪ (use your own first and last names, of course)

You might also like