Accessing Resources using Java Annotations, CDI, JDBC, and JPA

The hands-on lab is part of this learning path

Advanced Java Programming
course-steps 8 certification 1 lab-steps 6

Lab Steps

Logging in to the Amazon Web Services Console
Connecting to the Java Web IDE
Exercise 1 - Annotations
Exercise 2 - CDI
Exercise 3 - JDBC
Exercise 4 - JPA

Ready for the real environment experience?

Duration1h 30m


Lab Overview

Connecting to and consuming external resources such as databases, filesystems, and other data sources using Java is an essential skill needed to create applications that provide real enterprise business value.

This Lab is designed to expand your knowledge involving Java technologies like Annotations, CDI, JDBC, and JPA all of which can be used to help you access and consume external resources. You will be required to complete the following Java coding exercise:

  • Exercise 1 - Annotations: Complete the code required to implement 2 custom annotations, @Persist and @Identifier, which are then later used in combination to persist Employee objects out to the filesystem at runtime
  • Exercise 2 - CDI: Complete the code required to implement and use dependency injection using CDI (Contexts and Dependency Injection) to read Movie data stored in data file on the filesystem
  • Exercise 3 - JDBC: Complete the code required to connect to a Derby based SQL database using JDBC
  • Exercise 4 - JPA: Complete the code required to perfrom object relational mapping into a Derby based SQL database using JPA (Java Persistence API)

Note: The Modules exercise is supplied with a fully completed solution code for reference when required.

Lab Objectives

Upon completion of this Lab, you will be able to:

  • Be able to work confidently with Java Annotations
  • Implement and configure dependency injection using CDI
  • Implement, configure, and connect to SQL databases using JDBC
  • Understand the benefits of working with JPA to implement object relational mapping 
  • Run and debug the Java code and examine the results that are printed to the console

You should:

  • Be comfortable with using a browser based IDE

Lab Environment

This Lab will start with the following AWS resources provisioned automatically for you:

  • A single EC2 instance, named, which will have a public IP address attached. This instance will host a web based Java IDE (based on the Visual Code editor).

To achieve the Lab end state, you will be walked through the process of:

  • Using you local browser, access the web based Java IDE served from the
  • Completing the following lab exercises:
    • Exercise 1 - Annotations
    • Exercise 2 - CDI
    • Exercise 3 - JDBC
    • Exercise 4 - JPA


June 16th, 2018 - Optimized creation of Lab resources to reduce the time it takes to access the browser IDE by 60%

About the Author

Learning paths11

Jeremy is the DevOps Content Lead at Cloud Academy where he specializes in developing technical training documentation for DevOps.

He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 20+ years. In recent times, Jeremy has been focused on DevOps, Cloud, Security, and Machine Learning.

Jeremy holds professional certifications for both the AWS and GCP cloud platforms.

Covered Topics