java - JPAContainer connection? -


I am learning JPAContainer, and I can not understand how to configure my SGBD connection ... Using DAO mode I make A class that returns my connection

  // ConnectionFactory DAO mode public class ConnectionFactory {public connection getConnection (try {return  DriverManager.getConnection ("JDBC: mysql: // local host / fj21 "," Root "," "); } Hold (eclipse e) {new runtime exception (e); }}}  

How to use connection with JPAContainer to create connections? What better way?

"itemprop =" text ">

After defining your JPA persistent entity, lets say that" address book " . Then you can create a new JPAContainer using JPAContainerFactory

Example:.

  JPAContainerFactory.make (Person.class, JpaAddressbookApplication.PERSISTENCE_UNIT); // where PERSISTENCE_UNIT = "address book"  

In this way you are not going to need to deal with EntityManager .

My Strong Recommendation You can follow the tutorial and take a look at the following answer on stackoverflow:


Comments