Hello everyone, jpa has a long connection to the database. The database is located on a remote server. function that calls entityManager
public List<Posts> connect() throws UnsupportedEncodingException { EntityManager em=EntityManagerUtil.getEntityManagerFactory().createEntityManager(); Query q=em.createQuery("Select p from Posts p"); result=q.getResultList(); return result; }
persistence.xml
org.hibernate.jpa.HibernatePersistenceProvider
<properties> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/temp"/> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> <property name="hibernate.connection.username" value="user"/> <property name="hibernate.connection.password" value="user03022016"/> <property name="hibernate.archive.autodetection" value="class"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="true"/> <property name="hbm2ddl.auto" value="update"/> </properties> </persistence-unit>