Java Magazine, Sept/Oct 2018
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2018 31 the leading edge create table team_ roster id numeric first_ name varchar 150 last_ name varchar 150 position varchar 150 registration_ date date PRIMARY KEY ID Query service SportsTeamQueryService is the most straightforward because it involves only a few lines of code to produce especially if youre using an IDE Listing 1 shows the POM for this service because the service uses the EJB JPA and JAX RS Jakarta EE specifications All the code including the listings discussed but not inserted in this article is available from my GitHub repository A persistence unit is required so the service can connect to the database Listing 2 The service uses an entity class for persistence To create the TeamRoster entity class using Apache NetBeans select New Entity Classes from Database and then select the database table that was created in the previous section Listing 3 shows the codebase for the TeamRoster entity class A JAX RS service can be used to query the database To enable JAX RS within the service create an ApplicationConfig class with the contents of Listing 4 Listing 4 package org javamagazine sportsteamqueryservice service import java util Set import javax ws rs core Application @ javax ws rs ApplicationPath rest public class ApplicationConfig extends Application
You must have JavaScript enabled to view digital editions.