April 2018
Intermediate to advanced
202 pages
4h 48m
English
So, JPA is ready in the classpath. What could be the next logical step? It makes sense to define a connection to the database next. The simplest way of doing this is by creating a persistence.xml file. JPA will automatically read this file in the META-INF directory in your classpath. In a Maven project, the location is resources/META-INF/persistence.xml. Inside this file, you can define one or more persistence units (database connections) and its connection properties. The following is an example of a minimal persistence.xml file you can use to connect to the H2 database:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence ...
Read now
Unlock full access