You can define more persistence units in your persistence.xml file:
<persistence-unit name="pu1" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="javax.persistence.jdbc.url" value=""/>
<property name="javax.persistence.jdbc.user" value=""/>
<property name="javax.persistence.jdbc.password" value="/>
</properties>
</persistence-unit>
<persistence-unit name="pu2" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="javax.persistence.jdbc.url" value=""/>
<property name="javax.persistence.jdbc.user" value=""/>
<property name="javax.persistence.jdbc.password" value="/>
</properties>
</persistence-unit>
Now it depend if you are using full application server like TomEE or container (Tomcat).
@PersistenceContext(unitName = "pu1")
private EntityManager em;
@PersistenceContext(unitName = "pu2")
private EntityManager em2;
Otherwise:
Persistence.createEntityManagerFactory("pu1");
Persistence.createEntityManagerFactory("pu2");