29.3.6 Querying the Authors Table
Figure 29.1 performs a simple books database query that retrieves the Authors table and displays its data. The program illustrates using JPA to connect to the database and query it. You’ll use a dynamic query created in main to get the data from the database—in the next example, you’ll use auto-generated queries in the persistence unit to perform the same query and others. In Section 29.5, you’ll learn how to modify a database through a JPA persistence unit. Reminder: Before you run this example, ensure that the Java DB database server is running; otherwise, you’ll get runtime exceptions indicating that the app cannot connect to the database server. For details on starting the Java DB server, see Section 29.3.1 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access